Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Canny Edge detector threshold values gives different result

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.

like image 685
Rahul galgali Avatar asked Jul 21 '14 10:07

Rahul galgali


People also ask

What is the effect of changing threshold value in case of canny edge detection?

The reason is, at lower thresholds the Canny edge detector obtains too many edges, many of which may be weak and noisy. In contrast, when the thresholds were increased, only strong edges were detected; therefore, the robustness of the ARCSS detector increased. However, when the thresholds were increased above low = 0 .

Why does the Canny detector have two thresholds?

High threshold is used to identify the strong pixels (intensity higher than the high threshold) Low threshold is used to identify the non-relevant pixels (intensity lower than the low threshold)

What is threshold value in Canny edge detector?

The 'Canny' method uses two thresholds. For example, if the threshold is [0.1 0.15] then the edge pixels above the upper limit(0.15) are considered and edge pixels below the threshold(0.1) are discarded.

What are thresholds in Canny?

Canny does use two thresholds (upper and lower): If a pixel gradient is higher than the upper threshold, the pixel is accepted as an edge. If a pixel gradient value is below the lower threshold, then it is rejected.


1 Answers

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 :)

like image 87
Pervez Alam Avatar answered Sep 30 '22 04:09

Pervez Alam