Canny Edge Detector thresh2 > thresh1

Question:

I am currently writing a program in python using OpenCV and its function canny(). To find two good threshold values, I am using this code

http://mathalope.co.uk/2015/06/03/canny-edge-detection-app-with-opencv-python/

My question is: How exactly does the program "decide" which pixel is an edge pixel if the lower threshold is bigger than the upper one? I know how it works for upper>lower, but can’t grasp the process if it’s the other way round.

Thanks!

Asked By: Applecow

||

Answers:

The two thresholds are swapped if the low threshold is higher.

OpenCV is open source, so you can look at the source code:

if (low_thresh > high_thresh)
    std::swap(low_thresh, high_thresh);
Answered By: Miki
Categories: questions Tags: ,
Answers are sorted by their score. The answer accepted by the question owner as the best is marked with
at the top-right corner.