Biomedical Image Analysis in Python
Stephen Bailey
Instructor
$$1895$$
$$2017$$
Toolbox
imageio
: read and save imagesImage
objects are NumPy arrays.import imageio im = imageio.imread('body-001.dcm')
type(im)
imageio.core.Image
im
Image([[125, 135, ..., 110],
[100, 130, ..., 100],
...,
[100, 150, ..., 100]],
dtype=uint8)
im[0, 0]
125
im[0:2, 0:2]
Image([[125, 135],
[100, 130]],
dtype=uint8)
Metadata: the who, what, when, where and how of image acquisition
Accessible in Image
objects through the meta
dictionary attribute
im.meta
im.meta['Modality']
im.meta.keys()
Dict([('StudyDate', '2017-01-01'),
('Modality', 'MR'),
('PatientSex', F),
...
('shape', (256, 256)])
'MR'
odict_keys(['StudyDate',
'SeriesDate',
'PatientSex',
...
'shape'])
Matplotlib's imshow()
function displays 2D image data
Many colormaps available but often shown in grayscale (cmap='gray'
)
Axis ticks and labels are often not useful for images
import matplotlib.pyplot as plt
plt.imshow(im, cmap='gray')
plt.axis('off')
plt.show()
Biomedical Image Analysis in Python