Computer Vision · Beginner level

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

  1. Apply Canny to a photo with three threshold pairs.
  2. Blur first and compare the results.
  3. Choose thresholds that show cracks but not surface texture.
  4. 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

  1. What does hysteresis do in Canny?

    Show answer

    It keeps weak edges only if they connect to strong edges.

  2. 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.