Biomedical Image Analysis in Python
Stephen Bailey
Instructor
Ejection fraction: the proportion of blood pumped out of the heart's left ventricle (LV).
import scipy.ndimage as ndi im=imageio.imread('SCD4201-2d.dcm') filt=ndi.gaussian_filter(im, sigma=2) mask = filt > 150
labels, nlabels = ndi.label(mask)
nlabels
14
plt.imshow(labels, cmap='rainbow')
plt.axis('off')
plt.show()
Select a single label within image:
np.where(labels == 1, im, 0)
Select many labels within image:
np.where(labels < 3, im, 0)
Bounding box: range of pixels that completely encloses an object
ndi.find_objects()
returns a list of bounding box coordinates
labels, nlabels = ndi.label(mask) boxes = ndi.find_objects(labels)
boxes[0]
(slice(116,139), slice(120, 141))
Biomedical Image Analysis in Python