Biomedizinische Bildanalyse mit Python
Stephen Bailey
Instructor
Rohbild

Bildmaske

Logische Operationen ergeben True/False pro Pixel
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 ]])
Beispieloperationen
| Operation | Beispiel |
|---|---|
| Größer als | im > 0 |
| Gleich | im == 1 |
| X und Y | (im > 0) & (im < 5) |
| X oder 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)
steuert, welche Daten die Maske passieren.
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)

Biomedizinische Bildanalyse mit Python