The histogram is of essential importance in terms of characterizing
a given image, and it is a global description of the appearance of the image.
The histogram is the discrete version of the probability density distribution
of all available gray levels of the image:
Here is the code for finding the histogram of a given image:
For a gray level image to be properly displayed on screen, its pixel values
have to be within a proper range. For a 8-bit digital image there are
(from 0 to 255) gray levels. However, after applying certain
processing operations to the input image, the gray levels of the resulting
image are no longer necessarily within the proper range for display. In this
case rescaling of the image is needed: