การวิเคราะห์ภาพทางชีวการแพทย์ด้วย Python
Stephen Bailey
Instructor
ภาพดิบ

มาสก์ของภาพ

การดำเนินการเชิงตรรกะให้ผลลัพธ์เป็น True / False ที่แต่ละพิกเซล
mat = np.array([[1, 2, 3], [4, 5, 6], [7, 8, 9]])mat > 5
np.array([[False, False, False],
[False, False, True ],
[True, True, True ]])
ตัวอย่างการดำเนินการ
| การดำเนินการ | ตัวอย่าง |
|---|---|
| มากกว่า | im > 0 |
| เท่ากับ | im == 1 |
| X และ Y | (im > 0) & (im < 5) |
| X หรือ Y | (im > 10) | (im < 5) |
hist=ndi.histogram(im, 0, 255, 256)
mask1 = im > 32


mask2 = im > 64
mask3 = mask1 & ~mask2


np.where(condition, x, y)
ควบคุมว่าข้อมูลใดจะผ่านมาสก์
import numpy as npim_bone = np.where(im > 64, im, 0)
plt.imshow(im_bone, cmap='gray')
plt.axis('off')
plt.show()

m = np.where(im > 64, 1, 0)

ndi.binary_dilation(m,iterations=5)

ndi.binary_erosion(m,iterations=5)

การวิเคราะห์ภาพทางชีวการแพทย์ด้วย Python