EASTERN MEDITERRANEAN UNIVERSITY Electrical and Electronic Engineering E ngineering Department EE 583 (Digital Image Processing)
Home Work III
PREPARED BY:
LEONARDO O. IHEME IHEME (106054)
SUBMITTED TO: HasanD anDemirel Assoc Assoc.. Prof . Dr. Has
th
14 March, 2011
Edge Detection Techniques In simple terms, edge detection is the process of identifying points in a digital image where the brightness changes aggressively. Edges in images are areas with strong intensity contrasts±a jump in intensity from one pixel to the next. Edge detection is mainly used for feature detection or feature extraction in various fields. Inideal circumstances, the outcome of applying an edge detector to an image may lead to a set of connected curves that indicate the borders of objects, the borders of surface markings as well as curves that correspond to discontinuities in surface orientation. Thus, applying an edge detection algorithm 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. Usually gradient operators,laplacian operators and zero-crossing operators are used for edge detection. There are several approaches to edge detection but in this report, four of them are discussed. They differ mainly in t he types of smoothing filters that are applied and the way the measures of edge strength are computed. The techniques, their formulation and examples are discussed in the following sections.
Sobel operator The Sobel operator performs a 2-D spatial gradient measurement on an image. It uses a pair of 3×3 convolution masks, one estimating the gradient in the x-direction (columns) and the other estimating the gradient in the y-direction (rows). A convolution mask is usually much smaller than the actual image. As a result, the mask is slid over the image, manipulating a square of pixels at a time. TheSobel masks are shown below:
The magnitude of the gradient is given by:
The approximation of this magnitude is:
The Sobel operator is computationally cheap but it has the disadvantage of poor edge detection in the presence of noise. The operator highlights the noisy ar eas as edges, especially when the points are as large as a pixel.
Example Consider
the grey scale 256×256 image and the edges detected using the S obel operator
Figure 1a: Original Image
The Matlab code is as follows: I = imread( 'grass2.jpg' ); Edge = edge(I, 'sobel');
Figure 2b: Edges detected using the Sobel operator
imshow(Edge) imwrite(Edge, 'grass_sobel.jpg','jpg')
Prewitt operator This is a discrete differentiation operator that computes an approximation of the gradient of the image intensity function. The Prewitt operator is similar to the Sobel operator because it also involves convolving the image with a smaller integer valued filter in the vertical and horizontal direction. At each point in the image, the gradient vector points in the direction in which the highest intensity increase occurs; the length of this vector corresponds to the rate of change in that direction. Just like the Sobel operator, the Prewitt operator uses two 3×3 kernels which are convolved with the original image to ca lculate the approximations of the gradients. The Sobel masks are shown below:
The rest of the for mulation is the same as that of the Sobel operator. Again, it is a computationally cheap way of achieving edge detection but it still performs poorly in the presence of noise.
Example
Figure 2a: Original Image
Figure 2b: Edges detected using the Prewitt operator
The Matlab code is shown below
I = imread( 'grass2.jpg' ); Edge = edge(I, 'prewitt'); imshow(Edge) imwrite(Edge, 'grass_prewitt.jpg','jpg')
R obert operator Is a differential operator that operates by approximating the gradient of an image through discrete differentiation which is achieved by computing the sum of the squares of the differences between diagonally adjacent pixels. Unlike the Sobel and Prewitt operator, the Robert operator involves convolving the image with the ker nel in diagonal directions. According to Roberts, an edge detector should have the following properties: the produced edges should be well-defined, the background should contribute as little noise as possible, and the intensity of edges should correspond as close as possible to what a human would perceive[1]. With the set benchmarks in mind, the following equations were proposed:
where
the initial intensity value in the image is,
is the computed derivative and
represent the location in the image. The consequence of this procedure will focus on changes in intensity in a diagonal direction
.
The process of performing edge detection with the Robert operator is quite similar to the previously discussed operators in that two kernels are convolved with the image and then the absolute value of the gradient is taken as the new pixel value. The two Robert Kernels are:
These kernels are designed to respond maximally to edges running at
to the pixel grid,
one kernel for each of the two perpendicular orientations. The kernels can be applied separately to the input image, to produce separate measurements of the gradient component in each orientation. These can then be combined together to find the absolute magnitude of the gradient at each point and the orientation of that gradient.
and can be approximated as:
The Robert operator is very quick to compute but since it uses such a small kernel, it is very sensitive to noise. It also produces very wea k responses to genuine edges unless they are very sharp. The Sobel operator performs much better in this respect.
Example
Figure 3a: Original Image
Figure 3b: Edges detected using the Roberts operator
The Matlab code used is presented below I = imread( 'grass2.jpg' ); Edge = edge(I, 'roberts'); imshow(Edge) imwrite(Edge, 'grass_roberts.jpg' ,'jpg')
Canny
edge detector
In his paper,
Canny
followed a list of criteria to improve current methods of edge detection.
The first and most obvious is low error rate. It is important that edges occurring in images should not be missed and that there be no responses to non-edges. The second criterion is that the edge points be well localized. In other words, the distance between the edge pixels as found by the detector and the actual edge is to be at a minimum. A third criterion is to have only one response to a single edge. This was implemented because the first two were not substantial enough to completely eliminate the possibility of multiple responses to an edge. Based on these criteria, the canny edge detector first smoothens out the image to eliminate any noise. It then findsthe image gradient to highlight regions with high spatial derivatives. The algorithm then tracks along these regions and suppresses any pixel that is not at the
maximum (non-maximum suppression). The gradient array is now further reduced by hysteresis. Hysteresis is used to track along the remaining pixels that have not been suppressed. Hysteresis uses two thresholds and if the magnitude is below the first threshold, it is set to zero (made a non-edge). If the magnitude is above the high threshold, it is made an edge. And if the magnitude is between the two thresholds, then it is set t o zero unless there is a path from this pixel to a pixel with a gradient above the high threshold. For a detailed step by step description and mathematical formulation of the algorithm please refer to [2] and [3]. The
Canny
edge detector is known as an optimized edge detector because what it effectively
does is optimize the already existing edge detection algorithms; for example the Sobel operator is used to find the edge strength after the noise has been filtered out and before direction tracing. The algorithm has been lauded for its usage of probability for finding error rate, its localization and response, improvement of signal to noise ratio, and its better detection especially in noisy conditions. It however involves complex computations, false zero crossings and it is time consuming.
Example
Figure 3a: Original Image
The Matlab code is presented below:
Figure 3b: Edges detected using the Canny edge detector
I = imread( 'grass2.jpg' ); Edge = edge(I, 'canny'); imshow(Edge) imwrite(Edge, 'grass_canny.jpg' ,'jpg')
Conclusion
The comparison of the four presented edge detection techniques has shown that even though the classical methods (Sobel, Prewitt and Roberts) are computationally cheaper and less time consuming, the
Canny
edge detector is the most proficient because it uses probability for
finding error rate, localization and response; the cost of computation nowadays is not a big issue to contend with considering that there are high speed, high performance computer systems that perform complex computations in a matter of seconds. The figure below shows the result of the different methods used.
Original
Sobel
Prewitt
Roberts
Canny
Figure 4: Edge Detection Techniques
R eferences [1] Feature Detectors - Roberts Cross Edge Detector. (n.d.). Informatics Homepages Server . Retrieved March 13, 2011, from http://homepages.inf.ed.ac.uk/rbf/HIPR2/roberts.htm [2] Maini, R.,Aggarwal, H., Study and Comparison of Various Image Edge Detection Techniques, International Journal of I mage Processing, Vol. 3, No. 1, 2009, pp 1-11 [3]
Canny
edge detector. (n.d.). W ikipedia. Retrieved March 12, 2011, from en.wikipedia.org/wiki/Canny_edge_detector
[4] Roushdy,M., Comparative Study of Edge Detection Algorithms Applying on theGrayscale Noisy Image Using Morphological Filter , GVIP Journal, Vol. 6, No. 4, December, 2006
[5] Sobel operator. (n.d.). W ikipedia. Retrieved March 12, 2011, from en.wikipedia.org/wiki/Sobel_operator