0

I'm using matplotlib to generate some composite figures (from raw data and images). I'm trying to get the script to take image files of a few file formats, which are then plotted via:

Nxy = mpimg.imread(Nxy_filename)
imgplot = ax1.imshow(Nxy)

where ax1 is the subplot I want the image to show up in. This works fine for both PNG and JPEG images, but for a .bmp (of the same image) matplotlib seems to turn it blue, i.e.

enter image description here

turns into:

enter image description here

in my composite figure. On the other hand, the png and jpg files look exactly the same as the original. Any idea why this would happen? I'm reluctant to blindly alter the color map in the code since the other image formats appear as expected.

1
  • 1
    as a side note, you probably want to use imshow(..., interpolation='nearest') Commented Aug 5, 2013 at 22:57

1 Answer 1

2

It sounds like your PNG and JPEG images are RGB images that happen to be grey while the BMP image is grey scale. Check the shape of Nxy. My guess is it's two dimensional for the BMP while the PNG and JPEG image arrays have three dimensions.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.