0

I'm having a hard time with PIL library as what I see on my screen using plt.imshow(my_img_as_array) is always different from Image.fromarray(my_img_from_array).

More importantly, I'm plotting my image using plt.imshow and it gives me the following:

enter image description here

However, when I plot it using Image.fromarray it get this

enter image description here

Could anyone help me understand what is going on? Does it have anything to do with transparency?

Jeanne Chaverot
  • 147
  • 3
  • 11
  • 1
    Does [this](https://stackoverflow.com/questions/47290668/image-fromarray-just-produces-black-image) question help? – user15270287 Feb 26 '21 at 15:39
  • use plt.savefig('foo.png') and the load as Image.open with PILlow – pippo1980 Feb 28 '21 at 18:48
  • try mode='L' in Image.fromarray(my_img_from_array mode='RGBA') or Image.fromarray(img.astype('uint8'), mode='RGB') changing the mode according to https://pillow.readthedocs.io/en/4.2.x/handbook/concepts.html#concept-modes – pippo1980 Feb 28 '21 at 18:53
  • can you upload the array too ? – pippo1980 Mar 01 '21 at 17:14

0 Answers0