Skip to content
Search

Canny edge detector

lastmod 2023-11-05created 2017-06-2816 edits

The Canny edge detector is an edge detection operator that uses a multi-stage algorithm to detect a wide range of edges in images. It was developed by John F. Canny in 1986. Canny also produced a computational theory of edge detection explaining why the technique works.

It is a type of Edge detect algorithm.

Step

Since understanding the paper "A Computational Approach to Edge Detection" is not easy, to summarize it very simply as below, Canny edge consists of 4 steps.

  1. Blur the image with Gaussian Blur to remove noise.
  2. Find edges using the Sobel Edge Detector.
  3. Non-maxima Suppression: Use as an edge only where the Edge magnitude is a maximum. Here, instead of checking whether it is the maximum over all 3x3 neighbors, the search direction is determined by considering the edge orientaton.
  4. Connect the Edges (Hysteresis analysis)

Non-maxima Suppression

Use as an edge only where the edge magnitude is a maximum. Here, instead of checking whether it is the maximum over all 3x3 neighbors, the search direction is determined by considering the edge orientaton.

One of the characteristics of Canny Edge is that it uses two thresholds: in this process, if the edge magnitude is greater than the high threshold, the pixel is marked as an edge pixel, and if the magnitude is greater than the low threshold, it is marked as an edge when it is adjacent to an edge pixel later, when the edges are connected (hysteresis analysis).

Example

import cv2
import numpy as np
from matplotlib import pyplot as plt

img = cv2.imread('messi5.jpg',0)
edges = cv2.Canny(img,100,200)

plt.subplot(121),plt.imshow(img,cmap = 'gray')
plt.title('Original Image'), plt.xticks([]), plt.yticks([])
plt.subplot(122),plt.imshow(edges,cmap = 'gray')
plt.title('Edge Image'), plt.xticks([]), plt.yticks([])

plt.show()

See also

Favorite site

References


  1. Carstart.tistory.com_-Corner_Detection-_Canny_Edge.pdf ↩

  2. Gaussian37.github.io_-vision-concept-_edge_detection.pdf ↩

author Zer0 sitemap