开发者

finding Peaks in image Histogram

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 开发者_StackOverflowI 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


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.


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:

  • Compute all the extrema of the histogram (relative maxima/minima, including borders)
  • If there are only two maxima, AND if in between those maxima there is only one local minimum, we've found the valley. Return it.
  • Else, smooth the histogram (eg. a moving average) and go to first step.
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜