Multi-stage filter: Gaussian blur → gradient magnitude → non-maximum suppression → hysteresis thresholding. The standard preprocessing step before contour tracing.
Canny edge detection extracts sharp boundaries from a greyscale image in four stages. Each stage refines the result of the previous one, trading false positives against missed edges using two tunable thresholds.
A Gaussian kernel smooths the image before gradient computation, suppressing high-frequency noise that would otherwise produce spurious edges. Drag the σ slider to see how blur radius trades noise suppression against edge sharpness.
Left: noisy input. Right: after Gaussian blur.
The Sobel operator convolves the blurred image with two 3×3 kernels — one for horizontal (Gx) and one for vertical (Gy) change. The magnitude shows edge strength; the angle shows the normal to each edge.
Left: gradient magnitude. Right: gradient direction (hue = angle).
Each stage feeds into the next. Adjust σ to control blur strength before gradient computation; tune the two hysteresis thresholds to filter weak edges — pixels above high are always kept; pixels between low and high are kept only when connected to a strong edge.