I'm doing an exercise about matplotlib in which they show me the procedure to improve image intensity. After converting the image to an array and detecting the minimum and maximum values (RGB - 0 to 255):
# Extract minimum and maximum values from the image: pmin, pmax
pmin, pmax = image.min(), image.max()
print("The smallest & largest pixel intensities are %d & %d." % (pmin, pmax))
They propose the following:
# Rescale the pixels: rescaled_image
rescaled_image = 256*(image - pmin) / (pmax - pmin)
print("The rescaled smallest & largest pixel intensities are %.1f & %.1f." %
(rescaled_image.min(), rescaled_image.max()))
What is the logic behind this formula? 256 * (image - pmin) / (pmax - pmin)
Thanks :)
