matplotlib
Fork me on GitHub


Travis-CI:

Related Topics

This Page

MRIΒΆ

This example illustrates how to read an image (of an MRI) into a NumPy array, and display it in greyscale using imshow.

../../_images/sphx_glr_mri_demo_001.png
import matplotlib.pyplot as plt
import matplotlib.cbook as cbook
import matplotlib.cm as cm
import numpy as np


# Data are 256x256 16 bit integers
with cbook.get_sample_data('s1045.ima.gz') as dfile:
    im = np.fromstring(dfile.read(), np.uint16).reshape((256, 256))

fig, ax = plt.subplots(num="MRI_demo")
ax.imshow(im, cmap=cm.gray)
ax.axis('off')

plt.show()

Total running time of the script: ( 0 minutes 0.019 seconds)

Gallery generated by Sphinx-Gallery