Reputation: 57
I am witting a project of image processing. For some part of my project to find good threshold value I need to find peaks and valleys of image's histogram. I am witting my project in C# .net but I need Algorithm or sample code in any languages like(Java, C,C++,....) to understand the logic of that. I can convert to C# by my self. any document or algorithm or piece of code... thanks
Upvotes: 2
Views: 5179
Reputation: 21896
It's hard to beat Ohtsu's Method for binary thresholding. Even if you insist on implementing local extrema searching by yourself, Ohtsu's method will give you a good result to compare to.
Upvotes: 4
Reputation: 75896
If you already have computed your histogram, to find peaks and valleys is computationally trivial (loop over it and find local extrema). What is not trivial is to find "good" peaks and valleys to do some segmentation/threshold. But that is not a matter of coding, it's a matter of modelling. You can google for it.
If you want a simple recipe, and if you know that your histogram has "essentially" two peaks and a valley in the middle ("bimodal" histogram) and you want to locate that valley, I have once implemented the following ad-hoc procedure, with relative success:
Upvotes: 1