Viewing Images¶
How to use other packages with pydicom to view DICOM images
Introduction¶
pydicom is mainly concerned with getting at the DICOM data elements in files, but it is often desirable to view pixel data as an image. There are several options:
Use any of the many DICOM viewer programs available
use pydicom with matplotlib
use pydicom with Python’s stdlib Tkinter module.
use pydicom with Pillow
use pydicom with wxPython
Using pydicom with matplotlib¶
matplotlib can be used with the numpy.ndarray
from
Dataset.pixel_array
to display it:
>>> import matplotlib.pyplot as plt
>>> from pydicom import examples
>>> ds = examples.ct
>>> plt.imshow(ds.pixel_array, cmap=plt.cm.gray)
<matplotlib.image.AxesImage object at ...>