1. Home
  2. Docs
  3. Computer Vision
  4. Object Detection
  5. Edge Detection

Edge Detection

Canny Edge Detection

Canny Edge Detection is a popular edge detection algorithm used in computer vision to detect sharp discontinuities in an image.

Step 1: Noise Reduction (Gaussian Smoothing)

Since edge detection is susceptible to noise, the first step is to apply a Gaussian filter to smooth the image and reduce noise.

Step 2: Gradient Calculation

Compute the intensity gradients of the image using Sobel filters. This gives two gradient images: one in the x-direction and other in y-direction

Step 3: Non-maximum Suppression:

After calculating the gradient magnitude and direction, thin the edges by suppressing any pixel that is not considered to be a part of an edge. This is done by comparing the pixel intensity to its neighboring pixels along the gradient direction, and only retaining the local maxima.

Step 4: Double Threshold:

The algorithm uses two thresholds (a lower and a higher one) to classify edges:

  • Strong edges: Pixels with gradient magnitude above the high threshold.
  • Weak edges: Pixels with gradient magnitude between the high and low thresholds.
  • Non-edges: Pixels with gradient magnitude below the low threshold are discarded.

Step 5: Edge Tracking by Hysteresis:

Finally, weak edges are either discarded or accepted based on their connectivity to strong edges. If a weak edge is connected to a strong edge, it is considered part of an edge, otherwise, it is discarded.

edges = cv2.Canny(image, threshold1, threshold2)
  • image: The input image, usually in grayscale.
  • threshold1: The lower threshold value for edge detection.
  • threshold2: The upper threshold value for edge detection.

Loading

Views: 1

How can we help?

0 0 votes
Article Rating
Subscribe
Notify of
guest

0 Comments
Oldest
Newest Most Voted
Inline Feedbacks
View all comments