'Canny algorithm from openCV: What does the Threshold values really mean and why can they be higher than the values of the array?

I am trying to perform the Canny edge detection algorithm of OpenCV to an image array, whose values range from 0 to 255.

I am struggling to understand the role of the thresholds in the cv2.canny() function because for example, when I use threshold values of (MinThr=300, MaxThr=400) or (MinThr=350, MaxThr=450) I get different results. I don't understand why this happen since I thought that the Thresholds values that I define, couldn't be higher than the maximum value of the pixels in the array (in my case 255).

The other answers that I saw at Stackoverflow didn't help, so if someone could enlight me I would be very grateful. Thanks.



Solution 1:[1]

The thresholds are applied not to the original image intensity, but to its gradient magnitude, which maximal value is about 4 times larger than the maximal image intensity, because it is estimated using the Sobel operator. So you will stop seeing the difference (actually you will get an empty result) when the upper threshold exceeds 1000 and something. For details see Canny tutorial.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 aparpara