- Edge detection
**Edge detection**is a terminology inimage processing andcomputer vision , particularly in the areas of feature detection andfeature extraction , to refer toalgorithm s which aim at identifying points in adigital image at which the image brightness changes sharply or more formally has discontinuities.**Motivations**The purpose of detecting sharp changes in image brightness is to capture important events and changes in properties of the world. It can be shown that under rather general assumptions for an image formation model, discontinuities in image brightness are likely to correspond to:

* discontinuities in depth,

* discontinuities in surface orientation,

* changes in material properties and

* variations in scene illumination. In the ideal case, the result of applying an edge detector to an image may lead to a set of connected curves that indicate the boundaries of objects, the boundaries of surface markings as well curves that correspond to discontinuities in surface orientation. Thus, applying an edge detector to an image may significantly reduce the amount of data to be processed and may therefore filter out information that may be regarded as less relevant, while preserving the important structural properties of an image. If the edge detection step is successful, the subsequent task of interpreting the information contents in the original image may therefore be substantially simplified.Unfortunately, however, it is not always possible to obtain such ideal edges from real life images of moderate complexity.Edges extracted from non-trivial images are often hampered by "fragmentation", meaning that the edge curves are not connected, missing edge segments as well as "false edges" not corresponding to interesting phenomena in the image -- thus complicating the subsequent task of interpreting the image data.**Edge properties**The edges extracted from a two-dimensional image of a three-dimensional scene can be classified as either viewpoint dependent or viewpoint independent.A "viewpoint independent edge" typically reflects inherent properties of the three-dimensional objects, such as surface markings and surface shape.A "viewpoint dependent edge" may change as the viewpoint changes, and typically reflects the geometry of the scene, such as objects occluding one another.

A typical edge might for instance be the border between a block of red color and a block of yellow. In contrast a

**line**(as can be extracted by a ridge detector) can be a small number of pixels of a different color on an otherwise unchanging background. For a line, there may therefore usually be one edge on each side of the line.Edges play quite an important role in many applications of image processing, in particular for

machine vision systems that analyze scenes of man-made objects under controlled illumination conditions. During recent years, however, substantial (and successful) research has also been made on computer vision methods that do not explicitly rely on edge detection as a pre-processing step**A simple edge model**Although certain literature has considered the detection of ideal step edges, the edges obtained from natural images are usually not at all ideal step edges. Instead they are normally affected by one or several of the following effects:

* focal blur caused by a finitedepth-of-field and finitepoint spread function .

* penumbral blur caused by shadows created by light sources of non-zero radius.

*shading at a smooth object edge.

* local specularities or interreflections in the vicinity of object edges.Although the following model does not capture the full variability of real-life edges, the

error function $operatorname\{erf\}$ has been used by a number of researchers as the simplest extension of the ideal step edge model for modeling the effects of edge blur in practical applications (Zhang and Bergholm 1997, Lindeberg 1998).Thus, a one-dimensional image $f$ which has exactly one edge placed at $x\; =\; 0$ may be modeled as:$f(x)\; =\; frac\{I\_r\; -\; I\_l\}\{2\}\; left(\; operatorname\{erf\}left(frac\{x\}\{sqrt\{2\}sigma\}\; ight)\; +\; 1\; ight)\; +\; I\_l.$

At the left side of the edge, the intensity is $I\_l\; =\; lim\_\{x\; ightarrow\; -infty\}\; f(x)$, and right of the edge it is$I\_r\; =\; lim\_\{x\; ightarrow\; infty\}\; f(x)$.The scale parameter $sigma$ is called the blur scale of the edge.

**Why edge detection is a non-trivial task**To illustrate why edge detection is not a trivial task, let us consider the problem of detecting edges in the following one-dimensional signal. Here, we may intuitively say that there should be an edge between the 4th and 5th pixels.

5 7 6 4 152 148 149

If the intensity difference would be smaller between the 4th and the 5th pixels and if the intensity differencesbetween the adjacent neighbouring pixels would be higher, it would, however, not be as easy to say that there should bean edge in the corresponding region or, indeed, if there even could be multiple edges.Hence, to firmly state a specific threshold on how large the intensity change between two neighbouring pixels must be for us to say that there should be an edge between these pixels is not always a simple problem. Indeed, this is one of the reasons why edge detection may be a non-trivial problem unless the objects in the scene are particularly simple and the illumination conditions can be well controlled.**Approaches to edge detection**There are many methods for edge detection, but most of them can be grouped into two categories, search-based and zero-crossing based. The search-based methods detect edges by first computing a measure of edge strength, usually a first-order derivative expression such as the gradient magnitude, and then searching for local directional maxima of the gradient magnitude using a computed estimate of the local orientation of the edge, usually the gradient direction. The zero-crossing based methods search for zero crossings in a second-order derivative expression computed from the image in order to find edges, usually the zero-crossings of the Laplacian or the zero-crossings of a non-linear differential expression, as will be described in the section on differential edge detection following below.As a pre-processing step to edge detection, a smoothing stage, typically Gaussian smoothing, is almost always applied (see also

noise reduction ).The edge detection methods that have been published mainly differ in the types of smoothing filters that are applied and the way the measures of edge strength are computed. As many edge detection methods rely on the computation of image gradients, they also differ in the types of filters used for computing gradient estimates in the x- and y-directions.

Canny edge detection Canny (1986) considered the mathematical problem of deriving an optimal smoothing filter given the criteria of detection, localization and minimizing multiple responses to a single edge. He showed that the optimal filter given these assumptions is a sum of four exponential terms. He also showed that this filter can be well approximated by first-order derivatives of Gaussians.Canny also introduced the notion of non-maximum suppression, which means that given the presmoothing filters, edge points are defined as points where the gradient magnitude assumes a local maximum in the gradient direction.

Although his work was done in the early days of computer vision, the Canny edge detector (including its variations) is still a state-of-the-art edge detector. Unless the preconditions are particularly suitable, it is hard to find an edge detector that performs significantly better than the Canny edge detector.

The Canny-Deriche detector (Deriche 1987) was derived from similar mathematical criteria as the Canny edge detector, although starting from a discrete viewpoint and then leading to a set of recursive filters for image smoothing instead of exponential filters or Gaussian filters.

The differential edge detector described below can be seen as a reformulation of Canny's method from the viewpoint of differential invariants computed from a

scale-space representation.**Other first-order methods**For estimating image gradients from the input image or a smoothed version of it, different gradient operators can be applied. The simplest approach is to use central differences:

:$L\_x(x,\; y)=-1/2cdot\; L(x-1,\; y)\; +\; 0\; cdot\; L(x,\; y)\; +\; 1/2\; cdot\; L(x+1,\; y).,$:$L\_y(x,\; y)=-1/2cdot\; L(x,\; y-1)\; +\; 0\; cdot\; L(x,\; y)\; +\; 1/2\; cdot\; L(x,\; y+1).,$

corresponding to the application of the following filter masks to the image data:

:$L\_x\; =\; egin\{bmatrix\}\; -1/2\; 0\; 1/2\; end\{bmatrix\}\; *\; Lquad\; mbox\{and\}\; quad\; L\_y\; =\; egin\{bmatrix\}\; +1/2\; \backslash 0\; \backslash -1/2end\{bmatrix\}\; *\; L$

The well-known and earlier

Sobel operator is based on the following filters::$L\_x\; =\; egin\{bmatrix\}\; -1\; 0\; +1\; \backslash -2\; 0\; +2\; \backslash -1\; 0\; +1\; end\{bmatrix\}\; *\; Lquad\; mbox\{and\}\; quad\; L\_y\; =\; egin\{bmatrix\}\; +1\; +2\; +1\; \backslash 0\; 0\; 0\; \backslash -1\; -2\; -1\; end\{bmatrix\}\; *\; L$

Given such estimates of first- order derivatives, the gradient magnitude is then computed as:

:$|\; abla\; L|\; =\; sqrt\{\; L\_x^2\; +\; L\_y^2\}$

while the gradient orientation can be estimated as

:$heta\; =\; operatorname\{atan2\}(L\_y,\; L\_x)$

Other first-order difference operators for estimating image gradient have been proposed in the

Prewitt operator and Roberts cross.**Thresholding and linking**Once we have computed a measure of edge strength (typically the gradient magnitude), the next stage is to apply a threshold, to decide whether edges are present or not at an image point. The lower the threshold, the more edges will be detected, and the result will be increasingly susceptible to noise, and also to picking out irrelevant features from the image. Conversely a high threshold may miss subtle edges, or result in fragmented edges.

If the edge thresholding is applied to just the gradient magnitude image, the resulting edges will in general be thick and some type of edge thinning post-processing is necessary. For edges detected with non-maximum suppression however, the edge curves are thin by definition and the edge pixels can be linked into edge polygon by an edge linking (edge tracking) procedure. On a discrete grid, the non-maximum suppression stage can be implemented by estimating the gradient direction using first-order derivatives, then rounding off the gradient direction to multiples of 45 degrees, and finally comparing the values of the gradient magnitude in the estimated gradient direction.

A commonly used approach to handle the problem of appropriate thresholds for thresholding is by using thresholding with

hysteresis . This method uses multiple thresholds to find edges. We begin by using the upper threshold to find the start of an edge. Once we have a start point, we then trace the path of the edge through the image pixel by pixel, marking an edge whenever we are above the lower threshold. We stop marking our edge only when the value falls below our lower threshold. This approach makes the assumption that edges are likely to be in continuous curves, and allows us to follow a faint section of an edge we have previously seen, without meaning that every noisy pixel in the image is marked down as an edge. Still, however, we have the problem of choosing appropriate thresholding parameters, and suitable thresholding values may vary over the image.**Second-order approaches to edge detection**Some edge-detection operators are instead based upon second-order derivatives of the intensity. This essentially captures the

rate of change in the intensity gradient. Thus, in the ideal continuous case, detection of zero-crossings in the second derivative captures local maxima in the gradient.The early Marr-Hildreth operator is based on the detection of zero-crossings of the Laplacian operator applied to a Gaussian-smoothed image. It can be shown, however, that this operator will also return false edges corresponding to local minima of the gradient magnitude. Moreover, this operator will give poor localization at curved edges. Hence, this operator is today mainly of historical interest.

**Differential edge detection**A more refined second-order edge detection approach, which also automatically gives edges with sub-pixel accuracy,is by using the following "differential approach" of detecting zero-crossings of the second-order directional derivative in the gradient direction: Following a differential geometric way of expressing the requirement of non-maximum suppression (Lindeberg 1998), let us introduce at every image point a local coordinate system $(u,\; v)$, with the $v$-direction parallel to the gradient direction. Assuming that the image has been presmoothed by Gaussian smoothing and a

scale-space representation $L(x,\; y;\; t)$ at scale $t$ has been computed, we can require that the gradient magnitude of the scale-space representation, which is equal to the first-order directional derivative in the $v$-direction $L\_v$, should have its first order directional derivative in the $v$-direction equal to zero :$partial\_v(L\_v)\; =\; 0$ while the second-order directional derivative in the $v$-direction of $L\_v$ should be negative, i.e., :$partial\_\{vv\}(L\_v)\; leq\; 0$. Written out as an explicit expression in terms of local partial derivatives $L\_x$, $L\_y$ ... $L\_\{yyy\}$, this edge definition can be expressed as the zero-crossing curves of the differential invariant:$L\_v^2\; L\_\{vv\}\; =\; L\_x^2\; ,\; L\_\{xx\}\; +\; 2\; ,\; L\_x\; ,\; L\_y\; ,\; L\_\{xy\}\; +\; L\_y^2\; ,\; L\_\{yy\}\; =\; 0,$that satisfy a sign-condition on the following differential invariant:$L\_v^3\; L\_\{vvv\}\; =\; L\_x^3\; ,\; L\_\{xxx\}\; +\; 3\; ,\; L\_x^2\; ,\; L\_y\; ,\; L\_\{xxy\}\; +\; 3\; ,\; L\_x\; ,\; L\_y^2\; ,\; L\_\{xyy\}\; +\; L\_y^3\; ,\; L\_\{yyy\}\; leq\; 0$ where $L\_x$, $L\_y$ ... $L\_\{yyy\}$ denote partial derivatives computed from ascale-space representation $L$ obtained by smoothing the original image with a Gaussian kernel.In this way, the edges will be automatically obtained as continuous curves with subpixel accuracy.Hysteresis thresholding can also be applied to these differential and subpixel edge segments.In practice, first-order derivative approximations can be computed by central differences as described above, while second-order derivatives can be computed from the scale-space representation $L$ according to::$L\_\{xx\}(x,\; y)\; =\; L(x-1,\; y)\; -\; 2\; L(x,\; y)\; +\; L(x+1,\; y).,$:$L\_\{xy\}(x,\; y)\; =\; (L(x-1,\; y-1)\; -\; L(x-1,\; y+1)\; -\; L(x+1,\; y-1)\; +\; L(x+1,\; y+1))/4,\; ,$:$L\_\{yy\}(x,\; y)\; =\; L(x,\; y-1)\; -\; 2\; L(x,\; y)\; +\; L(x,\; y+1).,$

corresponding to the following filter masks:

:$L\_\{xx\}\; =\; egin\{bmatrix\}\; 1\; -2\; 1\; end\{bmatrix\}\; *\; Lquad\; mbox\{and\}\; quad\; L\_\{xy\}\; =\; egin\{bmatrix\}\; -1/4\; 0\; 1/4\; \backslash \; 0\; 0\; 0\backslash \; 1/4\; 0\; -1/4\; end\{bmatrix\}\; *\; Lquad\; mbox\{and\}\; quad\; L\_\{yy\}\; =\; egin\{bmatrix\}\; 1\; \backslash -2\; \backslash 1end\{bmatrix\}\; *\; L$

Higher-order derivatives for the third-order sign condition can be obtained in an analogous fashion.

**Phase Congruency Based Edge Detection**A recent development in edge detection techniques takes a frequency domain approach to finding edge locations.

Phase congruency (also known as phase coherence) methods attempt to find locations in an image where all sinusoids in the frequency domain are in phase. These locations will generally correspond to the location of a perceived edge, regardless of whether the edge is represented by a large change in intensity in the spatial domain. A key benefit of this technique is that it responds strongly toMach bands , and avoids false positives typically found around roof edges.**References***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.

* [*http://www.nada.kth.se/cvap/abstracts/cvap191.html Lindeberg, T., "Edge detection and ridge detection with automatic scale selection", International Journal of Computer Vision, 30, 2, pp 117--154, 1998.*]

* [*http://portal.acm.org/citation.cfm?id=264981&dl=GUIDE&coll=ACM W. Zhang and F. Bergholm: Multi-Scale Blur Estimation and Edge Type Classification for Scene Analysis, International Journal of Computer Vision, Volume 24, Issue 3, pages 219 - 250, 1997*]

* [*http://citeseer.ist.psu.edu/ziou97edge.html Ziou, D. and Tabbone, S.: Edge Detection Techniques An Overview, International Journal of Pattern Recognition and Image Analysis, 8(4):537--559, 1998*] (Contains an extensive set of references.)**ee also***

Canny edge detector

*Sobel operator

*Prewitt

*Roberts Cross

*Hough transform for detecting straight lines, circles or ellipses from edge points

*feature detection (computer vision) for other low-level feature detectors

*ridge detection for relations between edge detectors and ridge detectors

*scale-space for theory of Gaussian image smoothing and multi-scale feature detection

*image noise reduction

*atomic line filter for line detection------------------------

*Wikimedia Foundation.
2010.*