2
votes

Whenever I plot this image I get issues with the whites turning yellow. I know it's due to the default color mapping viridis, which matplotlib uses. When I switch to cmap='gray', it ends up showing the right red color pane.

Can anyone explain why this is happening? What color map should be used generally for pictures like this? How is the picture able to show the right colors when I do the default imshow(img)? What changes when I isolate the a single color pane? And when isolating red green or blue color panes in images, what is the preferred cmap and why?

Ipython Notebook

This is the output for the red color pane

The regular image plots correctly according to RGB color mode:

enter image description here

1
The difference is that when you use imshow on the entire image, imshow has the rgb data available and the default is to then just display the image. If you use just one channel (in your case red), what you are left with is grey scale data. When you use imshow on such data, the default is to use a color map in order to make differences more easily distinguishable. And the default colormap just happens to be viridis.Thomas Kühn

1 Answers

5
votes

The logic is rather simple, possibly the following chart helps more than any explanation.

enter image description here