Difference between hist and imhist
11 views (last 30 days)
Show older comments
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
0 Comments
Accepted Answer
Image Analyst
on 9 Aug 2014
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.
5 Comments
Image Analyst
on 8 Jul 2016
Yes. It does not care what format was used to store the image on disk, it just looks at an array of numbers, which is what you get when you read a disk file into MATLAB.
Nagabhushan SN
on 27 Aug 2018
Hi @ImageAnalyst, you've mentioned that "IMPORTANT WARNING: counts(1) is not for gray level 0!!!" So do you mean that hist doesn't give histogram in order of intensity values? So, histogram plots by imhist(grayImage) and hist(double(grayImage(:)), 256) will be different?
More Answers (0)
See Also
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!