Display image as grayscale using matplotlib

I’m trying to display a grayscale image using matplotlib.pyplot.imshow(). My problem is that the grayscale image is displayed as a colormap. I need the grayscale because I want to draw on top of the image with color.

I read in the image and convert to grayscale using PIL’s Image.open().convert(“L”)

image = Image.open(file).convert("L")

Then I convert the image to a matrix so that I can easily do some image processing using

matrix = scipy.misc.fromimage(image, 0)

However, when I do

figure()  
matplotlib.pyplot.imshow(matrix)  
show()

it displays the image using a colormap (i.e. it’s not grayscale).

What am I doing wrong here?

9 Answers
9

Leave a Comment