imhist(P,10) , imhist(P,256) What are the differences among resulting histograms?
3 次查看(过去 30 天)
显示 更早的评论
I'm a new MATLAB user. I don't understand the meaning of bins used in imhist command. Can someone tell me the differences between the resulting histograms imhist(P,10), imhist(P,256)
0 个评论
采纳的回答
Image Analyst
2013-3-16
A uint8 image might have intensities in the range of 0-255. If you use 256 bins, you get a count of how many pixels have each gray level. If you use 10 bins, you get a count of how many pixels are in the range 0-24, 25-49, 50-74, and so on.
更多回答(1 个)
Wayne King
2013-3-16
编辑:Wayne King
2013-3-16
It's the same meaning as the "regular" histogram, hist().
The number of bins in any histogram governs how coarsely or finely you bin the data. The fewer the bins, the wider the intervals and accordingly more values will fall in each bin. Conversely, the more bins, the shorter the intervals and fewer values will fall in each.
Choosing the optimal number of bins for your data is part science and part art. You want the histogram to give you a visual representation of the distribution of the data. Too few bins and the picture is too coarse. Too many bins and you end up not summarizing the data in any useful way.
Compare the following example with Gaussian random variables (just uses hist)
x = randn(1000,1);
subplot(221)
hist(x,30); title('30 bins');
subplot(222)
hist(x,4); title('4 bins');
subplot(223)
hist(x,400); title('400 bins');
I think you'll agree, the choice of 30 gives the best summary of the data distribution here.
0 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Histograms 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!