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:
function task1 a=imread('coins.png'); subplot(1,2,1) imshow(a); prob=zeros(1,255); [r c]=size(a); for h=1:255 for i=1:1:r for j=1:1:c if (a(i,j)==h) prob(h)=prob(h)+1; end end end end subplot(1,2,2) stem(prob)