Principle:Kornia Kornia Edge Detection
| Knowledge Sources | |
|---|---|
| Domains | Vision Image_Processing Filters |
| Last Updated | 2026-02-09 15:00 GMT |
Overview
Technique of identifying boundaries in images where pixel intensity changes sharply, forming edges that delineate object contours and structural features.
Description
Edge detection identifies locations in images with significant intensity gradients. The Canny edge detector is a multi-stage algorithm consisting of five key steps:
(1) Gaussian smoothing to reduce noise, (2) computing gradient magnitude and direction using Sobel operators, (3) non-maximum suppression to thin edges to single-pixel width, (4) double thresholding to classify strong and weak edges, and (5) hysteresis edge tracking to connect weak edges that are adjacent to strong edges.
The result is a binary edge map with clean, connected boundaries. Canny remains the gold standard for classical edge detection due to its noise robustness and edge connectivity.
Usage
Use when you need clean, thin edge maps for contour analysis, shape recognition, or as preprocessing for higher-level vision tasks. The Canny detector is differentiable in Kornia, enabling integration into training pipelines.
Theoretical Basis
The Canny edge detection pipeline proceeds through five stages:
Step 1 -- Gaussian blur: Smooth the input image to reduce noise.
Step 2 -- Gradient computation: Compute gradient magnitude and direction using Sobel operators.
Step 3 -- Non-maximum suppression: Suppress a pixel if its magnitude is less than its neighbor along the gradient direction. This thins edges to single-pixel width.
for each pixel (i, j):
if magnitude(i, j) < neighbor along gradient direction:
suppress(i, j)
Step 4 -- Double threshold: Classify edge pixels by strength.
Step 5 -- Hysteresis: Weak edges connected to strong edges are kept; isolated weak edges are removed. This ensures edge continuity.
for each weak edge pixel:
if any 8-connected neighbor is a strong edge:
promote to strong edge
else:
suppress