at what range histogram of 16 and 8 bins fall.
Show older comments
when i am trying to make a histogram of an image without imhist(). my values does not match.
i=imread('lena.tif');
[count,b]=imhist(i,16);
what is the value of b? is b a range or interval ? if yes then what it is for each bin?
my program without imhist()
imData=imread('lena.tif');
for i=1:m
for j=1:n
histo=imData(i,j);
if ((histo==0) || (histo<=15))
count(1)=count(1)+1;
elseif ((histo==16) || (histo<=31))
count(2)=count(2)+1;
:
:
:
elseif((histo==224) || (histo<=239))
count(15)=count(15)+1;
else
count(16)=count(16)+1;
end
end
my value of this 'count' doesn't match with previous by using imhist().
Accepted Answer
More Answers (1)
Walter Roberson
on 31 Dec 2012
I think the bins returned in "b" are the bin centers, such as would be returned by hist().
Note: you do not need the (histo==NUMBER) part of your code
if histo <= 15
count(1)=count(1)+1;
elseif histo <= 31
count(2)=count(2)+1;
and so on.
Or, much more compact, get rid of the if/elseif tree and use
binnum = 1 + floor(histo / 16);
count(binnum) = count(binnum) + 1;
1 Comment
preet
on 31 Dec 2012
Categories
Find more on Blue in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!