Edge Detection
Table of Contents
Description
Edge detection refers to the process of identifying and locating sharp discontinuities in an image. The discontinuities are abrupt changes in pixel intensity which characterize boundaries of objects in a scene. Classical methods of edge detection involve convolving the image with an operator (a 2-D filter), which is constructed to be sensitive to large gradients in the image while returning values of zero in uniform regions. There is an extremely large number of edge detection operators available, each designed to be sensitive to certain types of edges. Variables involved in the selection of an edge detection operator include:- Edge orientation: The geometry of the operator determines a characteristic direction in which it is most sensitive to edges. Operators can be optimized to look for horizontal, vertical, or diagonal edges.
- Noise environment: Edge detection is difficult in noisy images, since both the noise and the edges contain high-frequency content. Attempts to reduce the noise result in blurred and distorted edges. Operators used on noisy images are typically larger in scope, so they can average enough data to discount localized noisy pixels. This results in less accurate localization of the detected edges.
- Edge structure: Not all edges involve a step change in intensity. Effects such as refraction or poor focus can result in objects with boundaries defined by a gradual change in intensity. The operator needs to be chosen to be responsive to such a gradual change in those cases. Newer wavelet-based techniques actually characterize the nature of the transition for each edge in order to distinguish, for example, edges associated with hair from edges associated with a face.
Below is an example of two gradient filters that both detect edges oriented at about 135 degrees, but when approached from opposite directions:
Gradient #1 | Gradient #2 | ||||
0 | -1 | -1 | 0 | 1 | 1 |
1 | 0 | -1 | -1 | 0 | 1 |
1 | 1 | 0 | -1 | -1 | 0 |
| Gradient #1 highlights pixels where the light intensity increases along the direction going from northeast to southwest. It darkens pixels where the light intensity decreases along that same direction. This processing outlines the northeast front edges of bright regions such as the ones in the illustration. | Gradient #2 highlights pixels where the light intensity increases along the direction going from southwest to northeast. It darkens pixels where the light intensity decreases along that same direction. This processing outlines the southwest front edges of bright regions such as the ones in the illustration. | ||||
![]() | ![]() | ||||
Note: Applying Gradient #1 to an image gives the same results as applying Gradient #2 to its photometric negative, because reversing the look-up table of an image converts bright regions into dark regions and vice versa.
Often you are only interested in detecting edges along a single line profile of an image (to detect the presence of an object, for example). In that case, you can just identify a line or curve ROI and analyze the resulting line profile. The detected edges are shown as red dots in the image below:


Edge Parameters
There are many ways of describing an edge in terms of its intensity profile. Here we will discuss the three parameters used by the National Instruments edge detection functions. The diagram below illustrates the relationships of the parameters:

The top profile shown is a typical line profile that would be extracted from a line region of interest (ROI) that crosses an edge. The bottom (contrast) profile is obtained by filtering the line profile with an averaging and differencing filter. In the simplest case, it is just the slope of the line profile. The three parameters involved are:
Filter width: This is the size (length) of the filter used to obtain the contrast profile from the intensity profile. The filter averages two groups of a specified number of pixels on either side of the edge, then takes the difference between the two averages. Longer filters average more points and are less susceptible to identifying noise in the image as an edge; they are less accurate, however, in identifying the exact location of the edge.
Contrast: The contrast is the magnitude of the difference returned by the filtering operation. The user can specify a minimum contrast that must be exceeded in order to consider a point to be part of an edge.
Steepness: The steepness of the edge is measured in pixels and indicates how sharp or well-defined the edge is. The length of the region that exceeds the contrast threshold corresponds to the steepness of the edge.
The actual location of the edge is a matter of interpretation and is somewhat application-dependent. You can define the edge to be located at the beginning of the gradient (where it first exceeds the contrast threshold), at the end of the gradient, or anywhere between the two. Our algorithm returns the edge location as the midpoint of the edge region (halfway between the two crossings of the contrast threshold.
Common Applications
Alignment and gauging applications, and as a pre-processing step in many advanced image analysis applications.
What To Expect
A list of edge points, either along a single line or as an edge image.
Reader Comments | Submit a comment »
Legal
This tutorial (this "tutorial") was developed by National Instruments ("NI"). Although technical support of this tutorial may be made available by National Instruments, the content in this tutorial may not be completely tested and verified, and NI does not guarantee its quality in any way or that NI will continue to support this content with each new revision of related products and drivers. THIS TUTORIAL IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND AND SUBJECT TO CERTAIN RESTRICTIONS AS MORE SPECIFICALLY SET FORTH IN NI.COM'S TERMS OF USE (http://ni.com/legal/termsofuse/unitedstates/us/).


