plt.imshow shows color images for grayscale images in IPython

imRGB was a 3D matrix (height x width x 3).
Now imGray is a 2D matrix in which there are no colors, only a "luminosity" value. So matplotlib applied a colormap by default.

Read this page and try to apply a grayscale colormap or a different colormap, check the results.

plt.imshow(imGray, cmap="gray")

Use this page as reference for colormaps. Some colormap could not work, if it occurs try another colormap.

If you want to display a single-channel grayscale image, you should rescale the values to [0,1.0] with dtype=float32, and pyplot will render the grayscale image with pseudocolor. So should choose the colormap to gray.

plt.imshow(imGray/255.0, cmap='gray')

According to the documentation: Image tutorial

For RGB and RGBA images, matplotlib supports float32 and uint8 data types. For grayscale, matplotlib supports only float32. If your array data does not meet one of these descriptions, you need to rescale it.


Pseudocolor can be a useful tool for enhancing contrast and visualizing your data more easily. This is especially useful when making presentations of your data using projectors - their contrast is typically quite poor.