How can i fix the threshold automatically from the histogram?
2 views (last 30 days)
Show older comments
MoonPie1
on 16 Dec 2015
Commented: Image Analyst
on 16 Dec 2015
How can i fix the threshold automatically from the histogram?
0 Comments
Accepted Answer
Walter Roberson
on 16 Dec 2015
First you need to define how you want to make the selection.
In the general case, a histogram of values could have complexity equivalent to a list of random non-negative integers, with up to half of the values potentially being peaks. There could be multiple peaks of the same height; there could be multiple major modes.
3 Comments
Walter Roberson
on 16 Dec 2015
No, there is no function that combines all of those things.
You still have no defined how you want to make the selection; all you have done is restricted the number of bins without indicating how the threshold is to be chosen from the counts.
Image Analyst
on 16 Dec 2015
I don't think histogram equalization would be what she wants. I think that would just make the three gray levels 0, 128, and 255 instead of whatever they are. I think she needs to define what needs to be done after the threshold, for example call regionprops(), like
bw1 = grayImage == grayLevel1;
measurements1 = regionprops(logical(bw1), 'All');
bw2 = grayImage == grayLevel2;
measurements2 = regionprops(logical(bw2), 'All');
bw3 = grayImage == grayLevel3;
measurements3 = regionprops(logical(bw3), 'All');
If it's really NOT 3 gray levels but three humps in the histogram, then she'll have to come up with a automatic thresholding scheme to pick them out. Perhaps multithresh() would do a good job there.
Such speculation can often be reduced if the poster would have just included the image in the first posting.
More Answers (0)
See Also
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!