Canny Edge detector threshold values gives different result

人盡茶涼 提交于 2019-11-29 15:52:16

问题


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.


回答1:


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:

min_threshold = 0.66 * mean

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.

Happy Coding :)



来源:https://stackoverflow.com/questions/24862374/canny-edge-detector-threshold-values-gives-different-result

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!