Skip to content
tezvyn:

Walk me through Canny edge detection and why it beats Sobel thresholding

Source: Wikipedia: Canny edge detectorHardHow cards are made

Walk me through Canny edge detection and why it beats Sobel thresholding

Tests multi-scale edge detection and noise robustness versus raw gradient thresholding. Strong answer lists Gaussian blur, Sobel gradients, non-maximum suppression, double thresholding, hysteresis. Red flag: calling it blurred Sobel without hysteresis or NMS.

What's really being asked

Whether you view edge detection as a structured signal-processing pipeline or a single filter operation. Interviewers want to see that you understand why raw gradient magnitude thresholding produces thick, noisy, and discontinuous boundaries, and how Canny's design addresses each failure mode through explicit stages rather than magic.

The full answer

Five stages in sequence. First, Gaussian smoothing to attenuate high-frequency noise before differentiation amplifies it. Second, Sobel or similar gradient operators to compute magnitude and orientation at each pixel. Third, non-maximum suppression to thin multi-pixel-wide ridges down to single-pixel width by comparing each pixel to its neighbors along the gradient direction. Fourth, double thresholding to partition pixels into strong edges, weak edges, and non-edges using high and low thresholds. Fifth, edge tracking by hysteresis to retain weak pixels only if they are connected to strong pixels, which suppresses noise while preserving true contour continuity. The superiority claim should contrast this pipeline against naive Sobel thresholding: the latter yields thick edges because it lacks thinning, breaks contours because it lacks connectivity logic, and is less robust to noise because it lacks the hysteresis continuity test.

The mistakes people make

Describing Canny as just Sobel plus Gaussian blur and a threshold. Omitting non-maximum suppression entirely or confusing it with simple thresholding. Treating hysteresis as a single threshold or as morphological dilation rather than connectivity-based tracking. Claiming Canny guarantees closed contours; it improves continuity but does not guarantee closure. Failing to mention that gradient orientation is required for non-maximum suppression, not just magnitude.

What usually comes next

How do you choose the Gaussian sigma and the two thresholds in practice? What are the computational trade-offs versus modern learned edge detectors? How does the algorithm behave on low-contrast or texture-rich regions? Can you explain why non-maximum suppression uses interpolation between neighboring pixels rather than discrete directions? How would you adapt Canny to color or multispectral images?

A concrete example

Consider an autonomous vehicle camera detecting lane markings. A naive Sobel threshold on the road image returns thick, blurred responses from asphalt texture and shadow boundaries. After Canny's Gaussian smoothing, texture noise is reduced. Sobel gradients capture the lane edges. Non-maximum suppression thins each lane boundary to a one-pixel-wide curve. Double thresholding discards weak shadow gradients while marking strong lane paint edges. Finally, hysteresis tracking connects short weak segments of a dashed lane line to the strong segments, producing a continuous navigable contour that a simple threshold would have fragmented.

Interview question

Why does Canny use gradient orientation during non-maximum suppression?

  • a.To classify pixels into strong, weak, and non-edge categories
  • b.To determine which neighboring pixels to compare for ridge thinningCorrect
  • c.To track weak pixels connected to strong edges across the image
  • d.To attenuate noise prior to computing derivative approximations
Why?

Gradient orientation tells NMS which neighbors lie along the edge direction so it can thin multi-pixel ridges to single-pixel width. Option C describes hysteresis, which uses spatial connectivity rather than gradient direction to link edges.

Just read this? Test yourself on what you have been reading.

Read the original → en.wikipedia.org

You just looked this up. Could you explain it out loud?

That is the part interviews actually test. Tezvyn takes questions like this one and gives you what the interviewer is really checking, the answer that lands, and the mistake that ends the conversation, in the four minutes before your next meeting.

The iPhone app is on the way

We are building it. Until it lands, nothing here is held back from you: every interview card, your saved cards, streaks and the job board all work in Safari, plus hundreds of free practice quizzes of thirty questions each. Sign in and it all carries over to the app the day it arrives.

Want it as an icon? Tap Share at the bottom of Safari, then Add to Home Screen. It opens full screen and the cards you have read stay available offline.

Get it on Google PlayiPhone app coming soon

We are hiring for this. Open roles that interview on computer-vision — each one lists the topics its interview covers.

See open roles