Objects and Labels

Biomedical Image Analysis in Python

Stephen Bailey

Instructor

Segmentation splits an image into parts

cell-segmentation

brain-segmentation

Biomedical Image Analysis in Python

Sunnybrook Cardiac Database

Ejection fraction: the proportion of blood pumped out of the heart's left ventricle (LV).

ejection-fraction-illustration

Cardiac image

Biomedical Image Analysis in Python

Labeling image components

cardiac-2d-mask

Biomedical Image Analysis in Python

Labeling image components

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()

labeled-cells

Biomedical Image Analysis in Python

Label selection

Select a single label within image:

np.where(labels == 1, im, 0)

One label

Select many labels within image:

np.where(labels < 3, im, 0)

Two labels

Biomedical Image Analysis in Python

Object extraction

  • Bounding box: range of pixels that completely encloses an object

  • ndi.find_objects() returns a list of bounding box coordinates

labelled-image-with-bounding-boxes

Biomedical Image Analysis in Python

Object extraction

labels, nlabels = ndi.label(mask)
boxes = ndi.find_objects(labels)

boxes[0]
(slice(116,139), slice(120, 141))

multiple-image-boxes

Biomedical Image Analysis in Python

Let's practice!

Biomedical Image Analysis in Python

Preparing Video For Download...