Beginner level · Module 4: Image Filtering and Edge Detection · Lesson 3 of 3
The Canny Edge Detector
Learners apply Canny edge detection, tune its two thresholds and use edges to support simple visual inspection of infrastructure photos.
In this lesson you will
- Apply and tune the Canny edge detector
- Use edge maps in a simple inspection task
Key concepts
Canny stepsnon-maximum suppressionhysteresis thresholdscv2.Cannyparameter tuning
The lesson
Canny produces thin, connected edges in four steps: smooth with a Gaussian, compute gradients, keep only the strongest point across each edge (non-maximum suppression), and link edges using two thresholds (hysteresis). Strong edges above the high threshold are kept; weak edges between the thresholds are kept only if connected to strong ones.
cv2.Canny(gray, 100, 200) is a common starting point. Lower thresholds find more edges, including texture and noise; higher ones keep only the clearest outlines. A ratio of about 1:2 or 1:3 between the thresholds is a common rule of thumb.
Edge maps can help highlight possible cracks in concrete or erosion along a road, but they cannot judge structural safety. Present them as a tool that helps an engineer look, not as a decision.
Step by step
- Apply Canny to a photo with three threshold pairs.
- Blur first and compare the results.
- Choose thresholds that show cracks but not surface texture.
- Write how an engineer would use the output.
Practice activity
Build an edge-highlighting tool for inspection photos and document recommended settings.
Expected result: Tuned settings, before/after images and a clear statement of what the tool can and cannot show.
Check your understanding
-
What does hysteresis do in Canny?
Show answer
It keeps weak edges only if they connect to strong edges.
-
Can an edge map decide whether a bridge is safe?
Show answer
No. It only helps a qualified engineer inspect the image.
Further learning
Taught live by an instructor — online or in person. Free course lessons are for self-study and do not lead to a certificate — see registration options.