PIXELBANKv8.2.1
Menu

Canny Edge Detection Pipeline

HardEdges

Implement the complete Canny edge detection pipeline, a multi-stage process for detecting edges in images. The Canny edge detection algorithm is a widely used technique in Computer Vision for identifying and locating edges in images, which is crucial for various applications such as object recognition, image segmentation, and feature extraction.

The process involves several key steps, including Gaussian blur to reduce noise, gradient computation using Sobel operators to calculate the magnitude and direction of the gradient, non-maximum suppression to thin edges to 1 pixel width, and hysteresis thresholding to connect edges using two thresholds. The gradient magnitude is calculated as G=Gx2+Gy2G = \sqrt{G_x^2 + G_y^2}, where GxG_x and GyG_y are the horizontal and vertical gradient components.

  1. Apply Gaussian blur to the input image to reduce noise.
  2. Compute the gradient using Sobel operators to obtain the magnitude and direction of the gradient.
  3. Perform non-maximum suppression to thin edges to 1 pixel width by comparing each pixel to its neighbors along the gradient direction.
  4. Apply hysteresis thresholding to connect edges using two thresholds, where strong edges are retained and weak edges are only kept if connected to strong edges.
G=Gx2+Gy2G = \sqrt{G_x^2 + G_y^2}

This technique is widely used in image processing and analysis applications.

Example:

Input:
image = grayscale image with edges
low_threshold = 50
high_threshold = 150
Output:
Binary edge map with thin, connected edges
Reasoning:
  1. Blur removes noise
  2. Gradients show edge strength/direction
  3. NMS keeps only ridge points (local maxima)
  4. Hysteresis connects weak edges to strong ones

Constraints:

  • image: Grayscale image (H, W)
  • low_threshold: Lower threshold for hysteresis
  • high_threshold: Upper threshold for hysteresis
  • Return: Binary edge map
Editor

Test Results

0/0
Run code to see test results.