Session Ready
Exercise

Rescaling pixel intensities

Sometimes, low contrast images can be improved by rescaling their intensities. For instance, this image of Hawkes Bay, New Zealand has no pixel values near 0 or near 255 (the limits of valid intensities). (originally by Phillip Capper, modified by User:Konstable, via Wikimedia Commons, CC BY 2.0)

Hawkes Bay, New Zealand

For this exercise, you will do a simple rescaling (remember, an image is NumPy array) to translate and stretch the pixel intensities so that the intensities of the new image fill the range from 0 to 255.

Instructions
100 XP
  • Use the methods .min() and .max() to save the minimum and maximum values from the array image as pmin and pmax respectively.
  • Create a new 2-D array rescaled_image using 256*(image-pmin)/(pmax-pmin)
  • Plot the new array rescaled_image.