0

I am trying to save a PIL image that is in grayscale as a Numpy array, but everytime I do so, the resulting image is not saved in grayscale, it is saved as a colorful, green-ish image. I am using this code to save the image:

from PIL import Image
import os
from numpy import asarray
import matplotlib.pyplot as plt

image = Image.open('disparity_SGBM_norm.png')
npdata = asarray(image)
np.save("image", npdata)
plt.imshow(npdata)
plt.show()

So the original image is this, but after using matplotlib to draw the resulting array, it reveals that it was saved as this. Any idea why numpy is doing this, or is this because of matplotlib?

John Adams
  • 109
  • 10

0 Answers0