Canny Edge Detector thresh2 > thresh1


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

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.


Asked By: Applecow



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.