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:

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 ...>
../../_images/sphx_glr_plot_read_dicom_001.png