# Canny edge detector (Canny filter) for image processing and computer vision

N. Petkov and M.B. Wieling, University of Groningen,
Department of Computing Science, Intelligent Systems

This page contains explanation of parameters concerning a simulation program available on internet.

With the applet you can: use the Canny edge detector (Canny filter) for edge detection, visualize a derivative of a Gaussian function, simulate non-classical receptive field inhibition or surround suppression and use it for object contour detection.

The basic algorithm deployed for edge detection is that of J. Canny . You can use an additional surround suppression step that will eliminate texture edges . You should use this step if you are specifically interested in the detection of object contours and region boundaries.

## Explanation of operations and parameters

Canny edge detection starts with linear filtering to compute the gradient of the image intensity distribution function and ends with thinning and thresholding to obtain a binary map of edges. Surround inhibition is an optional additional step that can be performed between the linear filtering and the thinning and thresholding in order to suppress texture edges and obtain mainly occluding contours and region boundaries in the result.

### Linear filtering

This block implements two convolutions of the input image (intensity distribution function) with the x- and y-derivatives of a Gaussian function. (This is equivalent to first smoothing the input image with a Gaussian function and then computing the x- and y-derivatives.) The two convolution results present the x- and y-components of the scale dependent gradient of the image intensity distribution function.

Sigma (σ) - the standard deviation of the Gaussian function - is the only parameter of this step. Valid values are real positive numbers. Choose a small value (e.g. 1, 2 or 3) to detect sharp intensity transitions and a large value (e.g. 10 or 20) to detect gradual transitions.

To visualize one of the two filter kernels (x- and y-derivatives of the Gaussian function) choose the option "Filterkernel (x)" or "Filterkernel (y)" in the select window "Output image". The filter kernel will be calculated for the specified value of the parameter sigma (σ) and will be displayed as an intensity map image in the output window. It is also possible to display the power spectrum of the filter kernel. (Light and dark gray colors correspond to positive and negative function values, respectively.)

You can visualize the x- and y-components of the computed gradient separately or together. In either case you have to choose the option "Filter output" in the select window "Output image". To visualize the x- or y-component of the gradient, choose option "0" (for x) or option "90" (for y), respectively, in the select window "Displayed orientations" at the bottom of the parameter selection page and press the button "Change orientation(s)". To visualize the x- and y-components of the gradient simultaneously, click on "select all".

### Surround inhibition

The surround inhibition step does not make part of the original Canny edge detection algorithm. If you are only interested in Canny edge detection, you can skip this step by selecting the option "no surround suppression" (default) and go directly to thinning and thresholding.

The surround inhibition step is meant to suppress texture edges while leaving relatively unaffected the contours of objects and region boundaries. This biologically motivated mechanism introduced in  is particularly useful for contour-based object recognition. In that case, texture edges play the role of noise that obscures object contours and region boundaries and should preferably be eliminated.

Surround suppression type

Default is "no surround suppression". This corresponds to the original Canny algorithm.

If "isotropic surround suppression" is selected, all edges in the surroundings of a given edge have a suppression effect on that edge. The relative orientation of these edges has no influence on the suppression effect.

If "anisotropic surround suppression" is selected, the suppression effect of edges surrounding a given edge depends on their relative orientation: edges parallel to the considered edge have stronger suppression effect than oblique edges, and orthogonal edges have no effect.

Superposition for isotropic suppression

If "isotropic suppression" is selected, a superposition of the convolution results for the x- and y-orientations is computed and deployed for surround suppression. Different types of superposition can be used: L1, L2 and L-infinity norms.

Alpha (α)

This parameter controls the strength of surround suppression - the higher the value of Alpha (α), the more the strength (gradient magnitude) of an edge surrounded by other edges will be reduced. Default is 1 but one may need larger values in order to completely suppress texture edges.

K1 and K2

The surround that has a suppression effect on an edge in a given point has annular form with inner radius controlled by the combination of values of the parameters K1 and K2. The contribution of points in the annular surround is defined by a weighting function which is a half-wave rectified difference of Gaussian functions with standard deviations of K1σ and K2σ where σ is the standard deviation of the Gaussian function deployed in the linear filtering step. One can visualize the weighting function by selecting option "Inhibition kernel" under parameter "Output image".

The inner radius of the annular surround increases with K1. The size of the annual surround which has substantial contribution to the suppression increases with K2.

Default values are K1 = 1 and K2 = 4.

### Thinning and thresholding

These steps operate on the gradient magnitude computed in the linear filtering step and eventually changed by the surround inhibition step. If you are interested in the original Canny algorithm only, you should use only the steps thinning and hysteresis thresholding of edge strength.

Thinning thins edges in the output to one-pixel wide edges by non-maxima suppression.

Hysteresis thresholding of edge strength results in a binary output image. If it is enabled, two threshold values must be specified: T-high and T-low. These are given as fractions (between 0 and 1) of the maximum value of the gradient magnitude. Pixels with values higher than T-high are assigned the binary value 1 in the output, while pixels with values below T-low are assigned the binary value 0. Pixels with values between T-low and T-high are assigned the binary value 1 in the binary output if they can be connected to any pixel with a value larger than T-high through a chain of other pixels with values larger than T-low.

Hysteresis thresholding of contourness also results in a binary output image. It is only applied if a surround inhibition method is specified (isotropic or anisotropic surround suppression), even if the strength Alpha (α) of surround suppression is chosen to be 0. If it is enabled, two threshold values (between 0 and 1) must be specified: C-high and C-low. Only pixels which are assigned a binary value 1 in the previous hysteresis thresholding of edge strength are taken into account. This type of thresholding also operates on the gradient magnitude that represents the strength of an edge in a given point. It does not change the strength of edges but eliminates edges that are surrounded by many other edges (see  for details).

More precisely, in the case of isotropic suppression, the contourness of an edge point is computed as 1 - m*w / m, where m is the value of the gradient magnitude and m*w is the value of convolution of the gradient magnitude field with the inhibition kernel w in the concerned point. For a point in which the gradient magnitude is high while the gradient magnitude in the surroundings is small, the contourness will take a value near 1. This is the case for an edge that is not surrounded by other edges. For a point whose surroundings features high and numerous values of the gradient magnitude, a case typical of edge texture, the contourness will take a value near 0. In the case of anisotropic suppression, the contourness of a point is computed as 1 - |g.w*g / g.g|, where g is the gradient vector, w*g is the convolution of g with the inhibition kernel w, and the point "." denotes the dot product of two vectors.

## References

 Last changed: 2008-07-03