Canny Edge检测器阈值给出不同的结果 [英] Canny Edge detector threshold values gives different result

查看:208
本文介绍了Canny Edge检测器阈值给出不同的结果的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在尝试使用Canny的边缘检测器之前,我试图查找图像的轮廓. 对于不同的图像,它给出不同的结果.对于一张图像,它在阈值-min-40 max-240处给出完美的轮廓,对于其他图像则在30-120范围内给出轮廓. 我想使其通用.

I am trying to find contour of a image, before that I am applying Canny's edge detector. It's giving different result for different images.For one image it's giving perfect contours at threshold value - min-40 max-240 and for other image its 30-120. I want to make it generic.

推荐答案

用外行术语来说,边缘检测需要一个阈值,以告知应将哪些差异/变化算作边缘.有关详细信息,请在此处.

In laymen terms, edge detection needs a threshold to tell what difference/change should be counted as edge. For details read here.

因此,边缘取决于图像的内容,即亮度/暗度/对比度的水平. 我建议您简单地找到整个灰度图像的平均值,并采用以下阈值:

So, the edges depend on the the content of image ie the level of brightness/darkness/contrast. I suggest you to simply find the mean of whole gray image and take threshold as follows:

最小阈值= 0.66 *均值

min_threshold = 0.66 * mean

max_threshold = 1.33 *平均值

max_threshold = 1.33 * mean

我已经对其进行了测试,并且给出了令人印象深刻的结果.您可以使用中位数而不是均值,结果几乎相同.另一种选择是先均衡图像,然后尝试选择/实验的阈值.

I have tested it and it gives impressive result. You can use median instead of mean, with almost same result. Another alternative is to first equalize the image and then try threshold of your choice/experimental.

但是再次强烈建议尝试均值方法.如有任何疑问,请在此处写.

But again again strongly recommend to try mean method. In case of any query, write here.

快乐编码:)

这篇关于Canny Edge检测器阈值给出不同的结果的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆