Canny Edge Detector

Code Snippets

The Canny edge detector facilitates:

  • Good detection: finds all edges
  • Good localization: the found edges are as close as possible to the "real" edges in the image
  • Minimal response: one edge response is accepted for each position, i.e. avoiding multiple close or intersecting edge responses

Source image and the result after a Canny edge detection

The EasyImage Canny edge detector operates on a grayscale BW8 image and delivers a black-and-white BW8 image where pixels have only 2 possible values: 0 and 255. Pixels corresponding to edges in the source image are set to 255; all others are set to 0. It can adjust the scale analysis, it doesn't allow sub-pixel interpolation and it delivers a binary image after thresholding.

Canny edge detector example

The Canny edge detector requires only two parameters:

  • Characteristic scale of the features of interest: the standard deviation of the Gaussian filter used to smooth the source image.
  • Gradient threshold with hysteresis: maximum magnitude of the gradient of the source image expressed as a fraction ranging from 0 to 1 (two values).

The API of the Canny edge detector is a single class, ECannyEdgeDetector, with the following methods:

The result image must have the same dimensions as the input image.