ในการพล็อตขีดจำกัดฮิสเทรีซิสใน Matplotlib เราสามารถทำตามขั้นตอนต่อไปนี้ -
- กำหนดขนาดรูปและปรับช่องว่างภายในระหว่างและรอบๆ แผนผังย่อย
- สร้างร่างและชุดแผนย่อย
- โหลดเหรียญกรีก เหรียญกรีกจากปอมเปอี
- ค้นหา สูง , ต่ำ และ ขอบ ของภาพโดยใช้ sobel ตัวกรอง
- ใช้ขีดจำกัดฮิสเทรีซิสกับ "รูปภาพ"
- แสดงข้อมูลเป็นรูปภาพ เช่น บนแรสเตอร์ปกติ 2 มิติ โดยใช้ imshow() วิธีการ
- ตั้งชื่อสำหรับรูปภาพต้นฉบับและรูปภาพที่มีเกณฑ์ฮิสเทรีซิส
- หากต้องการแสดงรูป ให้ใช้ show() วิธีการ
ตัวอย่าง
import matplotlib.pyplot as plt
from skimage import data, filters
plt.rcParams["figure.figsize"] = [7.50, 3.50]
plt.rcParams["figure.autolayout"] = True
fig, ax = plt.subplots(nrows=1, ncols=2)
orig_img = data.coins()
edges = filters.sobel(orig_img)
low = 0.1
high = 0.4
low = (edges > low).astype(int)
height = (edges > high).astype(int)
hyst = filters.apply_hysteresis_threshold(edges, low, high)
ax[0].imshow(height + hyst, cmap='magma')
ax[0].set_xlabel('Hysteresis threshold')
ax[1].imshow(orig_img, cmap='magma')
ax[1].set_xlabel('Original Image')
plt.show() ผลลัพธ์
