MATLAB: Difference between hist and imhist

histImage Processing Toolboximhist

Hi,
I have a fundamental question about the hist and imhist and an explanation will be great as I am a bit lost.
I am running this script:
I = imread('pout.tif');
figure;
x=imhist(I)
imhist(I)
figure(2);
hist(x)
and when I compare the two histograms they do not look alike, why?
How can I save the imhist data so that the hist will show the same plot?
Thanks

Best Answer

For a gray scale image imhist() will give 256 bins. hist() only gives 10 by default. But you did not use hist() to take the histogram of the image - the badly-named "I". You used it to take a histogram of the histogram counts, x - a pretty weird/strange thing to do.