Edge Detection-Application of (First and Second) Order Derivative in Image Processing
Edge Detection-Application of (First and Second) Order Derivative in Image Processing
ABSTRACT: - Edge detection is one of the most frequently used techniques in digital
image processing. Edges typically occur on the boundary between two different regions in an
image. In this paper the first method we will find the edge for image by using (1st Order
Derivative Filter ) method. In this method we take the 1st derivative of the intensity value
across the image and find points where the derivative is maximum then the edge could be
located. The gradient is a vector, whose components measure how rapid pixel value are
changing with distance in the x and y direction. In second method we use the (2nd Order
Derivative Operators) .
The 2nd derivative of an image where the image highlights regions of rapid intensity
change and is therefore often used for edge detection zero crossing edge detectors. The zero
crossing detector looks for places in the Laplacian of an image where the value of the
Laplacian passes through zero i.e. points where the Laplacian changes sign. The criteria that
used to comparison of results is (Root mean square error ) for different threshold values that
explain the result obtain by 2nd order are best of the result obtain by 1st order for all values of
threshold.
1. INTRODUCTION
The goals of edge detection are: Produce a line drawing of a scene from an image of
that scene, Important features can be extracted from the edges of an image (e.g. corners, lines
and curve) and These features are used by higher-level computer vision algorithms (e.g.,
recognition).Various physical events cause intensity changes:(a. Geometric events such as
Object boundary where discontinuity in depth and/or surface color and texture and Surface
boundary where discontinuity in surface orientation and/or surface color and texture).
(b. Non-geometric events such as Specularity where direct reflection of light, i.e. a mirror,
Shadows (from other objects or from the same object and Inter-reflections). The edge
detection can be found by four steps:-
1- Smoothing: suppress as much noise as possible, without destroying the true edges.
2- Enhancement: apply a filter to enhance the quality of the edges in the image (sharpening).
3- Detection: determine which edge pixels should be discarded as noise and which should be
retained (usually, threshold provides the criterion used for detection).
4- Localization: determine the exact location of an edge (sub-pixel resolution
might be required for some applications, that is, estimate the location of an edge to better
than the spacing between pixels). Edge thinning and linking are usually required here.
The Criteria for good edge filters depend on some factor as following:-
i-No response to flat regions ⇒ Sum of mask values is zero: ∑(r, c) = 0.
ii- Isotropy: Response must be independent of edge orientation.
iii- Good detection: Minimize the probabilities of (detecting spurious edges caused by noise
and missing real edges)
430
Second Engineering Scientific Conference-College of Engineering –University of Diyala 16-17 December. 2015
EDGE DETECTION-APPLICATION OF (FIRST AND SECOND) ORDER DERIVATIVE IN IMAGE PROCESSING
iv- Good localization: Detected edges must be as close as possible to true edges. v- Single
response: Minimize number of false local maxima around true edge [1].
Where dx & dy measure distance along the x and y directions respectively. In discrete
images, one can consider dx & dy in terms of numbers of pixel between two points. dx = dy =
1 (pixel spacing) is the point at which pixel coordinates are(i, j) thus, the value of
(∆𝑥 𝑎𝑛𝑑 ∆𝑦) can calculated by equations (3) & (4).
∆𝑥 = 𝑓 (𝑖 + 1, 𝑗) − 𝑓(𝑖, 𝑗) … … … (3)
In order to detect the presence of a gradient discontinuity, one could calculate the
change in the gradient at (i, j) .This can be done by finding the following magnitude measure
and the gradient direction θ is given by the equation (5).
Diyala Journal of Engineering Sciences, Vol. 08, No. 04, Special Issue
431
Second Engineering Scientific Conference-College of Engineering –University of Diyala 16-17 December. 2015
EDGE DETECTION-APPLICATION OF (FIRST AND SECOND) ORDER DERIVATIVE IN IMAGE PROCESSING
∆𝑦
∅ = tan−1 [ ] … … . . (5)
∆
−1 1 −1 0
∆𝑥 = [ ], ∆𝑦 = [ ]
0 0 1 0
An advantage of using a larger mask size is that the errors due to the effects of noise
are reduced by local averaging within the neighborhood of the mask. An advantage of using a
mask of odd size is that the operators are centered and can therefore provide an estimate that
is based on a center pixel (i,j). One important edge operator of this type is the Sobel edge
operator. The Sobel edge operator masks are given as:
−1 0 1 1 2 1
[
∆𝑥 = −2 0 2], [
∆𝑦 = 0 0 0]
−1 0 1 −1 −1 −1
The operator calculates the gradient of the image intensity at each point, giving the
direction of the largest possible increase from light to dark and the rate of change in that
direction. The result therefore shows how "abruptly" or "smoothly" the image changes at that
point and therefore how likely it is that part of the image represents an edge, as well as how
that the edge is likely to be oriented. In practice, the magnitude (likelihood of an edge)
calculation is more reliable and easier to interpret than the direction calculation.
Mathematically, the gradient of a two-variable function (the image intensity function) at each
image point is a 2D vector with the components given by the derivatives in the horizontal and
vertical directions. At each image point, the gradient vector points to the direction of largest
possible intensity increase, and the length of the gradient vector corresponds to the rate of
change in that direction. This implies that the result of the Sobel operator at any image point
which is in a region of constant image intensity is a zero vector and at a point on an edge is a
vector which points across the edge, from darker to brighter values [3].
𝜕2𝑓 𝜕2𝑓
∆2 𝑓 = + … . … . . (6)
𝜕𝑥 2 𝜕𝑦 2
Diyala Journal of Engineering Sciences, Special Issue
432
Second Engineering Scientific Conference-College of Engineering –University of Diyala 16-17 December. 2015
EDGE DETECTION-APPLICATION OF (FIRST AND SECOND) ORDER DERIVATIVE IN IMAGE PROCESSING
𝜕2𝑓
For X-direction, = 𝑓 (𝑥 + 1, 𝑦) + 𝑓(𝑥 − 1, 𝑦) − 2𝑓(𝑥, 𝑦) … … . . (7)
𝜕𝑥 2
𝜕2𝑓
For Y-direction, = 𝑓 (𝑥, 𝑦 + 1) + 𝑓(𝑥, 𝑦 − 1) − 2𝑓(𝑥, 𝑦) … … . . (8)
𝜕𝑦 2
By substituting, Equations (7) and (8) in (6), we obtain the equation (9)
0 1 0
1 -4 1
0 1 0
ii. Thinning
Edge thinning is a technique used to remove the unwanted spurious points on the
edges in an image. This technique is employed after the image has been filtered for noise
(using median, Gaussian filter etc.), the edge operator has been applied to detect the edges
and after the edges have been smoothed using an appropriate threshold value. This removes
all the unwanted points and if applied carefully, results in one pixel thick edge elements. It
can be used for several applications, but is particularly useful for skeletonization. In this
mode it is commonly used to tidy up the output of edge detectors by reducing all lines to
single pixel thickness. Thinning is normally only applied to binary images, and produces
another binary image as output. The thinning operation is related to the hit-and-miss
transform, and so it is helpful to have an understanding of that operator before reading on.
Diyala Journal of Engineering Sciences, Vol. 08, No. 04, Special Issue
433
Second Engineering Scientific Conference-College of Engineering –University of Diyala 16-17 December. 2015
EDGE DETECTION-APPLICATION OF (FIRST AND SECOND) ORDER DERIVATIVE IN IMAGE PROCESSING
REFERENCE
1) Edge-Detection-Trucco, Chapt-4-AND-Jain-et-al-Chapt-5-Definition of Edges, Edges are
significant local changes of intensity.
2) Edge Detection Tutorial. Author: Bill Green, (2002).
3) A Descriptive Algorithm for Sobel Image Edge Detection, O. R. Vincent and O.
Folorunso, Proceedings of Informing Science & IT Education Conference (InSITE),
(2009).
4) Filtering Corrupted Image and Edge Detection in Restored Gray scale Image Using
Derivative Filters, Chandra Sekhar Panda,Prof. (Dr.) Srikanta Patnaik, International
Journal of Image Processing, (2009).
5) Digital Image Processing (3rd Edition) Hardcover, by Rafael C. Gonzalez & Richard,
(2007).
6) Numerical Methods for Engineers and Scientists, An Introduction with Applications using
MATLAB, Third Edition, Amos Gilat & Vish Subramaniam, (2014).
7) Digital Image Processing Algorithms and Application, by Ioannis Pitas, (2001).
8) Shapiro Computer and Robot Vision, Addison-Wesley Publishing Company, R. Haralick
and L., 1992.
9) E. Davies Machine Vision: Theory, Algorithms and Practicalities, Academic Press, 1990.
10) E. Gose, R. Johnsonbaug, S. Jost, Pattern Recognition and Image Analysis,
a. Prentice-Hall, Englewood Cliffs, NJ, 1996
11) A. Cumani, “Edge detection in multispectral images,” CVGIP: Graphical
a. Models and Image Proc. 1991.
b. D. Marr and E. Hildreth, "Theory of Edge Detection," Proceedings of the Royal Society
of London, B207, 1980.
Table (1): Show how the Value of Root Mean Square Error for (1st and 2nd) Derivative
Change with Different Value of Threshold.
No Threshold Value Rmse for 1st derivtive Rmse for 2nd derivtive
1 50 0.59743 0.51934
2 60 0.57274 0.49411
3 70 0.54882 0.54882
4 80 0.53078 0.4573
5 90 0.51542 0.44253
Diyala Journal of Engineering Sciences, Vol. 08, No. 04, Special Issue
435
Second Engineering Scientific Conference-College of Engineering –University of Diyala 16-17 December. 2015
EDGE DETECTION-APPLICATION OF (FIRST AND SECOND) ORDER DERIVATIVE IN IMAGE PROCESSING
Horizintal gradient 1st derivative : X axis Horizintal gradient 2nd derivative: X axis
Vertival gradient 1st derivative: Y axis Vertival gradient 2nd derivative: Y axis
Figure (10): Edge of Image for (1st and 2nd) Derivative with Threshold=50
Diyala Journal of Engineering Sciences, Vol. 08, No. 04, Special Issue
437
Second Engineering Scientific Conference-College of Engineering –University of Diyala 16-17 December. 2015
EDGE DETECTION-APPLICATION OF (FIRST AND SECOND) ORDER DERIVATIVE IN IMAGE PROCESSING
Figure (11): Edge after Thinning for (1st and 2nd) Derivative with Threshold=50
Figure (12): Edge after Threshold for (1st and 2nd) Derivative with Threshold=60
Figure (13): Edge after Thinning for (1st and 2nd) Derivative with Threshold=60
Figure (14): Edge after Threshold for (1st and 2nd) Derivative with Threshold=70
Figure (15): Edge after Thinning for (1st and 2nd) Derivative with Threshold=70
Figure (16): Edge after Threshold for (1st and 2nd) Derivative with Threshold=80
Diyala Journal of Engineering Sciences, Vol. 08, No. 04, Special Issue
439
Second Engineering Scientific Conference-College of Engineering –University of Diyala 16-17 December. 2015
EDGE DETECTION-APPLICATION OF (FIRST AND SECOND) ORDER DERIVATIVE IN IMAGE PROCESSING
Figure (17): Edge after Thinning for (1st and 2nd) Derivative with Threshold=80
Figure (18): Edge after Threshold for (1st and 2nd) Derivative with Threshold=90
Figure (19): Edge after Thinning for (1st and 2nd) Derivative with Threshold=90