Given a grayscale image, its histogram consists of the histogram of its gray levels; that is, a graph indicating the number of times each gray level occurs in the image.
We can infer a great deal about the appearance of an image from its histogram.
• In a dark image, the gray levels would be clustered at the lower end
• In a uniformly bright image, the gray levels would be clustered at the upper end.
• In a well contrasted image, the gray levels would be well spread out over much of the range.
Here is the Matlab Implementation: