About Edge Detection in Digital Images

. Edge detection is one of the most commonly used procedures in digital image processing. In the last 30–40 years, many methods and algorithms for edge detection have been proposed. This article presents an overview of edge detection methods, the methods are divided according to the applied basic principles. Next, the measures and image database used for edge detectors performance quantification are described. Ordinary users as well as authors proposing new edge detectors often use Matlab function without understanding it in details. Therefore, one section is devoted to some of Matlab function parameters that affect the final result. Finally, the latest trends in edge detection are listed. Picture Lena and two images from Berkeley segmentation data set (BSDS500) are used for edge detection methods comparison.


Introduction
Since there is a direct link between the edges in the image and the physical properties of the scene (the edges in the picture mostly represent the outline of the scene objects), a lot of scene information can be obtained from the edges detected in the image.Therefore, edge detection is one of the key operations in image processing.Mostly it is used for general goals such as image segmentation, boundary detection or object recognition.But edge detectors are also often used for special tasks like fire detection [1], carlicense plate detection [2], fingerprint identification [3], synthetic aperture radar (SAR) image processing [4][5][6], lunar surface crater topology [7], polyp detection in colonoscopy [8], etc.
Edge detectors convert a gray-scale or color image to a binary image -edge map that preserves much of the information content of the original image.Most methods can be divided into groups according to the basic principle they use.A brief description of the frequently applied edge detection methods is presented in Sec. 2. In the following two sections, the measures and image database used for edge detectors performance quantification are described.
Matlab function for edge detection is often applied as part of a larger process or it is used by authors to calculate edge maps by older algorithms for comparison with their new proposed methods.But both, users as well as authors of new edge detectors often use Matlab function without understanding it in details.They usually use this function with default settings but there are some function parameters which can be changed.The effect of these parameters on the final result is described in a separate section.In the final section the latest trends in edge detection are listed with focusing on edge detectors based on fractional differentiation.Picture Lena and some images from Berkeley segmentation data set (BSDS500) are used for computations.

Edge Detection Methods
The methods given in the next two subsections do not directly create an edge map, but their output is a gradient image (edge strength image) and the edge map of it is obtained using one of the methods listed in Sec.2.3.The whole process is illustrated in Fig. 1.

Gradient Edge Detectors
These detectors are based on the fact that the value of the image function f(x,y) changes significantly at the edge point.The change of function is expressed by its gradient f, a two-dimensional vector formed by the partial derivations Gradient magnitude f and orientation ψ can be computed from Pixels with high gradient magnitude are considered as edge points.The edge direction at a given point is perpendicular to the direction of the pixel gradient.Gradient operators are implemented using convolution masks.The most used operators are [9]: Kirsch Kx 5 3 3 5 0 3 Then edge strength ES(x,y) can be computed [5] from Edge strength images obtained by these operators are in Fig. 2. Canny [10] has chosen an analytic approach to the design of gradient operator for edge detection.He has defined three criteria that an optimal operator for edge detection should meet.Description of a detector can be simplified as follows.First, the Gaussian filter is applied.Then the derivative operators (corresponding masks) are used to compute gradient magnitude and direction.Then non-maximum suppression is used to get edges with a onepixel width.Finally, the threshold with hysteresis is applied to eliminate weak edges.Gradient magnitudes obtained by 5  5 Canny detectors are in Fig. 3.

Morphologic Edge Detectors
Morphological edge detectors can be considered as non-linear gradient operators, because they produce edge strength, similar to linear gradient operators.However, edge strength is obtained by non-linear morphological operations.The erosion e(k,l) of the gray scale image f(k,l) by a gray-scale structuring element g(k,l) is defined [11]   A simple edge detector producing edge strength G e (k,l) can be defined [12] e ( , ) ( , ) ( , ) ( , ) max ( , ) ( , ) where N 4 is 4-connected neighborhood.Similar detector can be defined also for 8-connected neighborhood.Edge strength images obtained by both detectors are in Fig. 4.
An edge detector can be defined also by dilatation.Then edge strength G d (k,l) is defined [12] d ( , ) ( , ) ( , ) where d(k,l) is a dilatation of the gray scale image f(k,l) by a gray-scale structuring element g(k,l) [11]   G e (k,l) and G d (k,l) shift the edge, each in the opposite direction.Their combination G de (k,l) eliminates this lack [12]   The above-mentioned edge detectors are very sensitive to noise in the processed image.To improve robustness of morphological edge detectors a new approach was proposed based on combination of the biwindow configuration with weighted median filters and anisotropic morphological directional derivatives [13].

Edge Map Creating
In order to obtain an edge map, after gradient operator application, it is necessary to use post-processing, such as some of the thresholding methods, the non-maximum suppression or a three-module strategy.

Thresholding
The most common way to get edge map is the simple thresholding or thresholding with hysteresis.The simple thresholding is defined [5] as the rule g(x,y) assigning the value V 1 or V 2 depending on the threshold value t to each point (x,y) of the input image f(x,y) V for ( , ) In practice, values V 1 , V 2 are often selected as the maximum or minimum of the image function, in the case of binary output image these values are 1 and 0. Edge strength values from gradient operators represent an input data for thresholding procedure.
Hysteresis thresholding for edge detection uses two thresholds t u > t d .Any pixel which has a value above the higher threshold t u is marked as edgel (=edge pixel).Any pixel whose value lies between the higher and lower thresholds and is connected to an edgel is also marked as edgel.Other points are rejected.
Thresholding produces wide edges.To get edges with a one-pixel width it is necessary to apply a suitable thinning procedure, usually morphological algorithm [14].Figure 5 shows the result of simple thresholding and morphological thinning.
Thresholding itself is not complicated, determining the appropriate threshold value, however, can pose quite a big problem.In the case of hysteresis thresholding, this is not critical, but for simple thresholding several methods for determining the optimal threshold have been developed.The triangle method [15] is based on the geometric shape of the edge strength histogram, but most methods are based on the statistical properties of the histogram.Some statistical methods for threshold determining are based on minimizing of the certain edge-histogram parameter, e.g. the overall entropy [16].In another method optimal threshold maximize the separability of the resultant classes in gray levels.[17].Sometimes, the thresholding is based on the specific features of the image to be processed (e.g. the radar image) [18].The above-mentioned procedures produce a threshold value which is valid for the whole image.
Sometimes it is more appropriate to use adaptive methods in which the image is divided into several smaller parts [19] or a small neighborhood is chosen for each point to calculate the threshold [20].

Non-maximum Suppression
Then non-maximum suppression (NMS) is used to get edges with a one-pixel width.It was proposed by Canny [21] as part of his edge detector operator but in principle it may be used with gradient operators that produce two edge parameters -edge strength and direction.
The pixel (x,y) is denoted M and two adjacent points perpendicular to the direction h of the edge (in the gradient direction u) are designated U and D (Fig. 6).U has coordinates (x,y + 1), (x -1,y), (x -1,y + 1) or (x + 1,y + 1), D has coordinates (x,y -1), (x + 1,y), (x + 1,y -1) or (x -1,y -1).If the edge strength at point U or D is greater than the edge strength at point M, then the point M is not considered as an edge point and the value of the output image function (edge map) at the point is set to the background value.Figure 7 shows two examples of using NMS.
Three-module strategy [22] is based on a similar principle as the non-maximum suppression.The first module computes local edge strength and direction, so any gradient operator that produces these two edge parameters can be used.The last module is a sequential process tracking edges.The originality of the method resides in the second module, which can be seen as a generalization of the nonmaximum suppression algorithm.

Zero-crossing Edge Detection
In the zero-crossing edge detectors, edges are detected as the location where the second derivative of the (usually smoothed) image crosses zero.The approximations of the second derivative are more sensitive to noise than the first derivative approximations.A sufficiently robust solution to this problem is the convolution of the image with a suitable filter [23], for example, whose convolutional mask corresponds to the Gaussian function G(x,y).Then Laplacian  2 is applied to the filtered image.Due to the linearity of derivation and convolution, the sequence of operations can be changed . (17) Operator that includes the second derivation as well as Gaussian filter is denoted Laplacian of Gaussian (LoG) Elements h(x,y) of the convolutional mask can be calculated where c is a normalization constant.In practice, the approximation of the LoG by this convolutional mask is often used Response of LoG is not processed by thresholding but it is inspected whether the sign has changed within the mask of 2  2 pixels around the examined point.Figure 8a shows the response of the above-mentioned 5  5 LoG convolutional mask applying for image Lena.The mid brightness value (gray points) represents a zero response, high brightness values correspond to positive response values and a low brightness values to negative response values.The resulting map of the edges (detected zero crossings) is in Fig. 8b.

Other Edge Detectors
So far, many methods for edge detection have been published, and not all can be described here in details.However, some methods should be described briefly, at least.
The image often contains complex information in the sense that it contains small objects visible only in close-up view and, on the other hand, large objects that are evident when viewed from a greater distance and whose contours do not have such sharp edges (compared to small details).Therefore, some authors apply multiscale approach to edge detection.A few multiscale methods are based on morphological edge detectors.One method [11] applies the same morphological edge detector to compute edge strength G n d (k,l) at various scales.The resulting edge strength G d (k,l) is calculated by where N 1 , N 2 is the range of used scales and w n are the weighing coefficients chosen by the user.This edge detector was slightly improved by removing the short edges in individual scales before the final summation [24].Other multiscale detection method [25] combines Canny's detector and scale multiplication.
A truly comprehensive tool for multiscale edge detection is wavelet transformation [26], [27].Mallat [26] has shown that a multiscale Canny edge detection is equivalent to finding the local maxima of a wavelet transform with smoothing function equal to Gaussian function.Multiscale approach combines local maxima of a wavelet transform found at various scales to get the resulting edge map [28] or multiplies the wavelet coefficients at two adjacent scales [29].
Edge detectors for color images form a specific category and can be divided into three groups: methods with outputs fusion, methods based on color vector and multidimensional gradient detector.Methods based on output fusion apply a suitable edge detector to each color component separately, creating three component edge maps.These maps are then combined into the resulting edge map, most often using logical sum [30], [31].Multidimensional gradient methods calculate gradients for individual color components, combining them into the resulting function representing edge strength.Koschan [32] uses Sobel operator to compute gradients for each color component.Then for each pixel mean value of color gradients is computed and thresholded to get final edge map.The main problem of the above-mentioned two groups of edge detectors for color images is how to combine edge maps or gradients of color components.Vector methods do not have this problem and appear to be optimal for detecting edges in color images.The most commonly used vector methods [33], [34] are based on vector order statistics (VOS).

Edge Detection Performance
To compare the various edge detection techniques, it is necessary to design some quantitative criteria for the edge detection performance.Peli and Malah [35] have proposed a number of quantitative measures to study the performance of the edge detectors: percentage of edge points detected on the ideal (desired) edge, number of edge points that do not coincide with the ideal edge (normalized by the number of points on the edge), noise-to-signal ratio and mean width of a detected edge.If all the points of the detected edges create a set W d with a number of points I d , and the actual edge points create a set W i with a number of points I i , then the correctly detected edge points form a set (W d ∩ W i ) with a number of points I c and incorrectly detected edge points form a set (W d -W i ) with a number of points I e = I d -I c .Percentage C A of edge points detected on the ideal (desired) edge is defined Percentage C E of edge points that do not coincide with the ideal edge (normalized by the number of points on the edge) is computed by Mean width of a detected edge C w is The above parameters do not include the shift of the detected edge with respect the actual one.So Pratt has introduced a figure of merit FoM [9] that balances above mentioned three measures (excluding noise-to-signal ratio)

Berkeley Segmentation Data Set
In order to correctly evaluate the edge detector performance, it is necessary to have real edges for comparison.It is not a problem in the case of artificially created images.However, edge detection is mainly used to process natural images.In 2001, Martin et al. have introduced The Berkeley Segmentation Database (BSD) [36], a large dataset of natural images that have been manually segmented.The human annotations serve as a ground truth for comparing different segmentation and boundary detection algorithms.A few years later, Martin et al. presented BSDS300, the collection of 300 pictures with their manual segmentations [37].The images are divided into a training set of 200 images, and a test set of 100 images.For the researchers proposing new methods, the authors of BSDS300 have prepared a guideline.All the learning, parameter tuning, etc. should be done exclusively on the train set.After training, the proposed algorithm should be run only once with fixed parameters on the set of testing images.The pictures and ground-truths of the test set cannot be used for tuning parameters of the proposed algorithm.
The human segmented images provide ground truth boundaries.Any boundary marked by a human subject can be considered to be valid.Since each image has multiple segmentations by different subjects, it is the collection of these human-marked boundaries that constitutes the ground truth, a soft boundary map with one-pixel wide boundaries, valued from zero to one where higher values indicate greater match with a boundary.Figure 9 and Figure 10 show two images from BSDS300, their manual segmentations and ground truths.Normally, a ground truth is a binary image with real edges.In the case of BSDS, a ground truth is a grey scale image where high values of luminance signify greater confidence in the existence of a boundary.
A new database BSDS500 is currently available.It is an extension of the BSDS300, where the original 300 pictures are used for training or validation and 200 new pictures, with manual segmentations, are added for testing.
Image segmentation is the process of partitioning a digital image into multiple segments and it is typically used to identify objects and boundaries in pictures.Edge detectors look for edge points (edgels), the pixels of a digital image at which the intensity changes rapidly.An edge is the boundary between two regions of different constant intensity.It means that image segmentation and edge detection are not the identical processes.This should be taken into account when evaluating the edge detector performance based on segmentations from BSDS500, especially, when the results of segmentation from different people vary considerably (Fig. 10e).

Edge Detection in Matlab
Matlab software is a very useful tool for image processing.There is a special Matlab function edge which can be directly used for edge detection.The syntaxes for this function are [14]:
For gradient edge detectors Matlab function edge uses thresholding to get the final edge map.Users can set threshold values manually with function syntax BW = edge(I,method,thr).If threshold parameter thr is missing, function calculates its value automatically.To get this calculated threshold value, users can apply syntax [BW,thrOut] = edge(___).For Sobel, Prewitt and Roberts methods it is possible to get the directional gradient magnitudes by syntax [BW,thrOut,Gv,Gh] = edge(___).For the Sobel and Prewitt operators, Gv and Gh correspond to the vertical and horizontal gradients, for the Roberts operator, Gv and Gh are the gradients at angles of 45° and 135° from horizontal direction.
The Sobel and Prewitt detector can identify edges in the horizontal direction or vertical direction (or both).The Roberts detector can find edges at angles of 45° from horizontal, 135° from horizontal, or both.Users can apply syntax BW = edge(I,method,thr,dir) to specify the orientation dir of detected edges.For Sobel, Prewitt and Roberts detector it is possible to skip the step of edge thinning by syntax BW = edge(___,'nothinning').The syntax BW = edge(I,method,thr,sigma) specifies the standard deviation sigma of the filter used in LoG or Canny edge detectors.

New Trends in Edge Detection
Over the last ten years, new approaches to edge detection have been presented, for example dictionary learning [44], [45] or fuzzy logic [46], [47].The most promising methods are based on fractional derivatives [3,39,43], [48][49][50].Generalized form of the Grunwald-Letnikov fractional derivative d α f(x) of order α is [51] 0 0 where m is an integer number and u and l are the integer upper and lower limits of differentiation, l < α ≤ u.Γ(z) is the gamma function given by [51] 1 0 ( ) To get fractional derivative mask for edge detection the fractional derivatives  α x f(x,y) and  α y f(x,y) along x and y axes can be simplified as follows [39] and K ≥ 3 is an integer representing the size of fractional derivative mask.The magnitude of the fractional gradients  α f(x,y) is given by The y-directional fractional mask of three rows can be computed by [39] (33) and the x-directional fractional mask of three columns can be computed by [39] Experiments have shown that the appropriate values of parameters α and K for edge detection are α = 1.2 and K = 3 [39].Then the particular directional fractional masks for edge detection are Similarly to classical gradient edge detectors, even for edge detection based on fractional derivation, it is necessary to use thresholding and thinning to get edges with a one-pixel width.Figure 11 shows the magnitude of fractional derivation (Fig. 11g) and corresponding edges after thresholding and thinning (Fig. 11h).Magnitude image was thresholded by the value of 0.4157, which was calculated by

Conclusion
Matlab function for edge detection is often applied as part of a larger process or it is used by researchers to calculate edge maps by older algorithms for comparison with their new proposed methods.Almost always this function is used with default settings, though there are some function parameters which can affect the results significantly.Table 1 and Table 2 show that the threshold value calculated automatically does not guarantee optimal edge maps.
Over the last ten years, new approaches to edge detection have been presented.The most promising methods are based on fractional derivatives.In the paper edge detector based on simple directional fractional derivative masks is presented.Magnitude image obtained by these masks was thresholded and thinned to get edges with a one-pixel width.The results presented in Tab. 3 and Tab. 4 show that edge detection based on fractional derivatives produces comparable or better results than older gradient methods, such as Prewitt, Sobel, etc.
δ is a scale constant (usually 1/9) and e(k) is the pixel-miss distance of the k-th edge point.It is clear that 0 ≤ FoM ≤ 1.The more the detected edges match the real edges, the closer the value of FoM is to 1.If FoM = 1, then two compared binary images (edge maps) are the same.Binary image with real edges is often referred to as a ground truth.
[17]ich was calculated by Otsu's method[17].From the result presented in Tab. 3 and Tab. 4 it is clear that Prewitt and Sobel edge detectors produce almost identical edges.It can be also concluded that edge detection based on fractional derivatives produces comparable or better results than older gradient methods, such as Prewitt, Sobel, etc.

Authors ...
Peter KUBINEC was born in 1966.He graduated from the Slovak University of Technology in Bratislava with Ph.D. degree in 2010.His Ph.D. work was focused on reverberator algorithms in digital audio signal processing.His research interests cover audio-video technique and audio signal analysis.He gives a lecture on microcontroller and digital signal processor programming techniques.