I am trying to open images (.png
) using PIL. However, It only shows images only in two colours.
Original image (i.e. 3.24 MB). I reduced the size since system only allows us to upload below 2MB:
When I run image = Image.open('path/image')
, it gives this:
when I run the same but with convert, image = Image.open('path/image').convert('L')
I get this:
Here is the way how i plot images:
fig,ax = plt.subplots()
ax.imshow(image)
ax.grid(False)
I have tried dozens of images. No change. I strongly guess the problem caused by the image channels. Function somehow reads the 3-channels as single-channel or the other way around. Any ideas how to fix???
Edit: So I got closer to the result i want. I convert the iamge into an array first. But it still is not enough.
here is the code:
image = Image.open(df['Path'][0])
image = np.asarray(image)
plt.imshow(image)