필터 지우기
필터 지우기

imhist(P,10) , imhist(P,256) What are the differences among resulting histograms?

조회 수: 1 (최근 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)

채택된 답변

Image Analyst
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
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.

카테고리

Help CenterFile Exchange에서 Images에 대해 자세히 알아보기

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by