# How to count the number of extrema of image's histogram

1 view (last 30 days)
HongTu Nguyen on 18 Sep 2011
Hi everyone, Please give me some suggest the ways to count the number of extrema of image's histogram. Thank a lot! Nice weekend for all! HongTu
##### 0 CommentsShow -2 older commentsHide -2 older comments

Sign in to comment.

### Accepted Answer

bym on 18 Sep 2011
im = imread('pout.tif');
[counts ,x]=imhist(im);
counts(x > 200)
##### 0 CommentsShow -2 older commentsHide -2 older comments

Sign in to comment.

### More Answers (1)

HongTu Nguyen on 19 Sep 2011
@proecsm: Thanks for your suggestion!
Sorry, my question is not clear. I mean that I want to guess the number of objects in image. Here is my thought:
• I have a histogram of image: [counts x] = imhist(image);
• I want to find its all local maxima from counts corresponding with indices from x into array.
-> is there any function for it?
Thanks.
##### 3 CommentsShow 1 older commentHide 1 older comment
HongTu Nguyen on 21 Sep 2011
Many thanks for your comment.
Yes, I saw blobsdemo. But I just want to guess how many object based on histogram. I'm learning about image segmentation. I use the eigenvectors to partion image, and then use k-means to group similar partions. So, I need to know how many the general objects. Then I choose histogram to guess that. But I don't know how to find local maxima of histogram.
Image Analyst on 21 Sep 2011
You can't estimate the number of foreground objects in your image from the image's histogram unless you know the areas of the objects in your image. For example if your foreground (objects) are brighter than thresholdValue and the size of the objects is objectArea, then you can estimate the number of objects like this:
numberOfObjects = round(sum(pixelCounts(thresholdValue:end)) / objectArea);

Sign in to comment.

### Categories

Find more on Histograms 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!