Session Ready
Exercise

Pseudocolor plot from image data

Image data comes in many forms and it is not always appropriate to display the available channels in RGB space. In many situations, an image may be processed and analysed in some way before it is visualized in pseudocolor, also known as 'false' color.

In this exercise, you will perform a simple analysis using the image showing an astronaut as viewed from space. Instead of simply displaying the image, you will compute the total intensity across the red, green and blue channels. The result is a single two dimensional array which you will display using plt.imshow() with the 'gray' colormap.

Instructions
100 XP
  • Print the shape of the existing image array.
  • Compute the sum of the red, green, and blue channels of img by using the .sum() method with axis=2.
  • Print the shape of the intensity array to verify this is the shape you expect.
  • Plot intensity with plt.imshow() using a 'gray' colormap.
  • Add a colorbar to the figure.