# Convert RGB Image to Grayscale and Display It (Python + Matplotlib) [closed]

I just started learning image processing and I was trying to read a RGB image then convert it to grayscale. I was hoping for something like this:

However, what I get was:

I tried using both scipy and PIL but they yield the same results. Am I lacking of understanding about grayscale image here?

Using scipy:

from scipy import misc
plt.imshow(car)


Using PIL:

from PIL import Image
pil_im = Image.open('image.jpg')
pil_imgray = pil_im.convert('LA')

img = np.array(list(pil_imgray.getdata(band=0)), float)
img.shape = (pil_imgray.size[1], pil_imgray.size[0])
plt.imshow(img)


## closed as off-topic by Peter K.♦Sep 13 '17 at 15:41

This question appears to be off-topic. The users who voted to close gave this specific reason:

• "General programming questions are off-topic here, but can be asked on Stack Overflow." – Peter K.
If this question can be reworded to fit the rules in the help center, please edit the question.

• Welcome to DSP.SE! This is just an RTFM question about plt.imshow and, as such, is not a signal processing question. – Peter K. Sep 13 '17 at 15:42
• It works for me: just use misc.imshow(car) instead of plt.imshow(car). – MBaz Sep 13 '17 at 15:45

You need to set the cmap properties of the imshow() function:
plt.imshow(img, cmap = "gray")