Canny edge detector

Canny edge detector

The Canny edge detection operator was developed by John F. Canny in 1986 and uses a multi-stage algorithm to detect a wide range of edges in images. Most importantly, Canny also produced a "computational theory of edge detection" explaining why the technique works.

Development of the Canny algorithm

Canny's aim was to discover the optimal edge detection algorithm. In this situation, an "optimal" edge detector means:
* "good detection" - the algorithm should mark as many real edges in the image as possible.
* "good localization" - edges marked should be as close as possible to the edge in the real image.
* "minimal response" - a given edge in the image should only be marked once, and where possible, image noise should not create false edges.

To satisfy these requirements Canny used the calculus of variations - a technique which finds the function which optimizes a given functional. The optimal function in Canny's detector is described by the sum of four exponential terms, but can be approximated by the first derivative of a Gaussian.

Stages of the Canny algorithm

Noise reduction

Because the Canny edge detector uses a filter based on the first derivative of a Gaussian, it is susceptible to noise present on raw unprocessed image data, so to begin with, the raw image is convolved with a Gaussian filter. The result is as a slightly blurred version of the original which is not affected by a single noisy pixel to any significant degree.

Here is an example of a 5x5 Gaussian filter, used to create the image to the right, with sigma = 0.4:

:mathbf{B} = frac{1}{159} egin{bmatrix} 2 & 4 & 5 & 4 & 2 \4 & 9 & 12 & 9 & 4 \5 & 12 & 15 & 12 & 5 \4 & 9 & 12 & 9 & 4 \2 & 4 & 5 & 4 & 2end{bmatrix} * mathbf{A}

Finding the intensity gradient of the image

An edge in an image may point in a variety of directions, so the Canny algorithm uses four filters to detect horizontal, vertical and diagonal edges in the blurred image. The edge detection operator (Roberts, Prewitt, Sobel for example) returns a value for the first derivative in the horizontal direction (Gy) and the vertical direction (Gx). From this the edge gradient and direction can be determined:

mathbf{G} = sqrt{ {mathbf{G}_x}^2 + {mathbf{G}_y}^2 }

mathbf{Theta} = operatorname{arctan}left({ mathbf{G}_y over mathbf{G}_x } ight)

The edge direction angle is rounded to one of four angles representing vertical, horizontal and the two diagonals (0, 45, 90 and 135 degrees for example).

Non-maximum suppression

Given estimates of the image gradients, a search is then carried out to determine if the gradient magnitude assumes a local maximum in the gradient direction. So, for example,
* if the rounded angle is zero degrees the point will be considered to be on the edge if its intensity is greater than the intensities in the north and south directions,
* if the rounded angle is 90 degrees the point will be considered to be on the edge if its intensity is greater than the intensities in the east and west directions,
* if the rounded angle is 135 degrees the point will be considered to be on the edge if its intensity is greater than the intensities in the north east and south west directions,
* if the rounded angle is 45 degrees the point will be considered to be on the edge if its intensity is greater than the intensities in the south east and north west directions.This is worked out by passing a 3x3 grid over the intensity map.

From this stage referred to as non-maximum suppression, a set of edge points, in the form of a binary image, is obtained. These are sometimes referred to as "thin edges".

Tracing edges through the image and hysteresis thresholding

Intensity gradients which are large are more likely to correspond to edges than if they are small. It is in most cases impossible to specify a threshold at which a given intensity gradient switches from corresponding to an edge into not doing so. Therefore Canny uses thresholding with hysteresis.

Thresholding with hysteresis requires two thresholds - high and low. Making the assumption that important edges should be along continuous curves in the image allows us to follow a faint section of a given line and to discard a few noisy pixels that do not constitute a line but have produced large gradients. Therefore we begin by applying a high threshold. This marks out the edges we can be fairly sure are genuine. Starting from these, using the directional information derived earlier, edges can be traced through the image. While tracing an edge, we apply the lower threshold, allowing us to trace faint sections of edges as long as we find a starting point.

Once this process is complete we have a binary image where each pixel is marked as either an edge pixel or a non-edge pixel. From complementary output from the edge tracing step, the binary edge map obtained in this way can also be treated as a set of edge curves, which after further processing can be represented as polygons in the image domain.

Differential geometric formulation of the Canny edge detector

A more refined approach to obtain edges with sub-pixel accuracy is by using the approach of differential edge detection, where the requirement of non-maximum suppression is formulated in terms of second- and third-order derivatives computed from a scale-space representation (Lindeberg 1998) -- see the article on edge detection for a detailed description.


The Canny algorithm contains a number of adjustable parameters, which can affect the computation time and effectiveness of the algorithm.

* The size of the Gaussian filter: the smoothing filter used in the first stage directly affects the results of the Canny algorithm. Smaller filters cause less blurring, and allow detection of small, sharp lines. A larger filter causes more blurring, smearing out the value of a given pixel over a larger area of the image. Larger blurring radii are more useful for detecting larger, smoother edges - for instance, the edge of a rainbow.
* Thresholds: the use of two thresholds with hysteresis allows more flexibility than in a single-threshold approach, but general problems of thresholding approaches still apply. A threshold set too high can miss important information. On the other hand, a threshold set too low will falsely identify irrelevant information (such as noise) as important. It is difficult to give a generic threshold that works well on all images. No tried and tested approach to this problem yet exists.

To experiment with the parameters of the Canny algorithm, the on-line Canny application on can be useful.


The Canny algorithm is adaptable to various environments. Its parameters allow it to be tailored to recognition of edges of differing characteristics depending on the particular requirements of a given implementation. In Canny's original paper, the derivation of the optimal filter led to a Finite Impulse Response filter, which can be slow to compute in the spatial domain if the amount of smoothing required is important (the filter will have a large spatial support in that case). For this reason, it is often suggested to use Rachid Deriche's Infinite Impulse Response form of Canny's filter (the Canny-Deriche detector), which is recursive, and which can be computed in a short, fixed amount of time for any desired amount of smoothing. The second form is suitable for real time implementations in FPGAs or DSPs, or very fast embedded PCs. In this context, however, the regular recursive implementation of the Canny operator does not give a good approximation of rotational symmetry and therefore gives a bias towards horizontal and vertical edges.


* Canny, J., "A Computational Approach To Edge Detection", IEEE Trans. Pattern Analysis and Machine Intelligence, 8:679-714, 1986.
* R. Deriche, "Using Canny's criteria to derive an optimal edge detector recursively implemented", Int. J. Computer Vision, Vol. 1, pp. 167-187, April 1987.
* [ Lindeberg, Tony "Edge detection and ridge detection with automatic scale selection", International Journal of Computer Vision, 30, 2, pp 117--154, 1998. (Includes the differential approach to non-maximum suppression.)]

ee also

*Edge detection
*Feature detection (computer vision)
*Feature extraction
*Scale space
*Ridge detection
*Computer vision
*Digital image processing

External links

* [ John Canny's home page]
* [ On-line Canny edge detector]
* [ Free Java implementation of Canny edge detector]
* [ Publication List of Rachid Deriche]

Wikimedia Foundation. 2010.

Игры ⚽ Поможем написать реферат

Look at other dictionaries:

  • Edge detection — is a terminology in image processing and computer vision, particularly in the areas of feature detection and feature extraction, to refer to algorithms which aim at identifying points in a digital image at which the image brightness changes… …   Wikipedia

  • Canny — may refer to:* Canny (attribute), a pleasant attribute * Canny edge detector, an operator which uses a multi stage algorithm to detect a wide range of edges in images * Paddy Canny (1919 2008), Irish fiddlercanny systems [] …   Wikipedia

  • Algoritmo de Canny — Este artículo está huérfano, pues pocos o ningún artículo enlazan aquí. Por favor, introduce enlaces hacia esta página desde otros artículos relacionados …   Wikipedia Español

  • JPEG — For other uses, see JPEG (disambiguation). Joint Photographic Experts Group A photo of a cat compressed with successively more lossy compression ratios from right to left Filename extension .jpg …   Wikipedia

  • Comparison of image processing software — The following table provides a comparison of image processing software. Functionality Matlab*[1] Mathematica[2] imageJ FIJI (software) Population Extract alpha channel No …   Wikipedia

  • List of computer vision topics — This is a list of computer vision and image processing topics Contents 1 Image enhancement 2 Transformations 3 Filtering, Fourier and wavelet transforms and image compression …   Wikipedia

  • Marr–Hildreth algorithm — In computer vision, the Marr–Hildreth algorithm is a method of detecting edges in digital images, that is continuous curves where there are strong and rapid variations in image brightness. The Marr–Hildreth edge detection method is simple and… …   Wikipedia

  • Shape context — is the term given by Serge Belongie and Jitendra Malik to the feature descriptor they first proposed in their paper Matching with Shape Contexts in 2000cite conference author = S. Belongie and J. Malik title = Matching with Shape Contexts url =… …   Wikipedia

  • Corner detection — Feature detection Output of a typical corner detection algorithm …   Wikipedia

  • Feature detection (computer vision) — In computer vision and image processing the concept of feature detection refers to methods that aim at computing abstractions of image information and making local decisions at every image point whether there is an image feature of a given type… …   Wikipedia

Share the article and excerpts

Direct link
Do a right-click on the link above
and select “Copy Link”