How to calculate width and height of histogram

I have an image data, whose histogram , i am calculating through hist command(not imhist) and then i get two parameters: one centroid of the bin, and another is no. of pixels in a bin, i want to calculate height and width of each bin. Pls help

 채택된 답변

Wayne King
Wayne King 2014년 2월 28일
편집: Wayne King 2014년 2월 28일

0 개 추천

I'm not sure I understand that information is returned by hist()
X = randn(100,1);
[N,bincntr] = hist(X);
Now you know the count in each bin and the bin centers.
To find the boundaries, you can just do
Dx = mean(diff(bincntr));
Now you get the intervals as [bincntr-Dx/2, bincntr+Dx/2]
They are all of width Dx and height equal to the corresponding N

댓글 수: 4

Parul
Parul 2014년 2월 28일
But i am applying hist on image data, not a simple data, take some image and then try to do this.
It does not make any difference - simple data or image data - they're both arrays of numbers and the bin width is just the distance between any of the bin centers. They should all be the same width so you can just do
binWidth = bincntr(2)-bincntr(1);
So now bincntr should still be a vector, but N will be a matrix with each column the output of binning each column of the data matrix.
If you look across the rows of the matrix, N, you see the division among the bin centers given by the vector bincntr.
Parul
Parul 2014년 3월 3일
I hv uploaded the pic, please go through the link given below. http://tinypic.com/r/2871y0j/8
and from its hist u will get to know, which height, width of the bin i am talking about..

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

도움말 센터File Exchange에서 Histograms에 대해 자세히 알아보기

질문:

2014년 2월 28일

댓글:

2014년 3월 3일

Community Treasure Hunt

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

Start Hunting!

Translated by