寻找图像直方图中的峰值
我正在做一个图像处理的项目。 对于我的项目的某些部分,为了找到良好的阈值,我需要找到图像直方图的峰值和谷值。 我正在用 C# .net 编写我的项目 但我需要任何语言的算法或示例代码,例如(Java,C,C++,....)来理解其逻辑。我可以自己转换成C#。 任何文档或算法或代码... 谢谢
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
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
对于二进制阈值,很难击败 Ohtsu 方法。即使您坚持自己实现局部极值搜索,Ohtsu 的方法也会给您一个很好的结果进行比较。
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.
如果您已经计算了直方图,则查找峰和谷在计算上是微不足道的(循环它并查找局部极值)。重要的是找到“好的”峰和谷来进行一些分割/阈值。但这不是编码的问题,而是建模的问题。您可以 google 查找它。
如果您想要一个简单的配方,并且如果您知道您的直方图“本质上”有两个峰和中间的一个谷(“双峰”直方图)并且您想找到该谷,我曾经实施过以下临时程序,相对成功:
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: