To implement the following edge detectors

advertisement
Edge Detection
Om Pavithra Bonam and Sridhar Godavarthy
University of South Florida
{obonam, sgodavar}@cse.usf.edu
Computer Vision (CAP 6415 : Project 2)
1 Abstract
In this project, we implement 4 popular edge detectors – Roberts, Prewitt, Sobel and Laplacian of
Gaussian and compare their performances. The dataset used for comparing consists of 10 different
images. Additional datasets are generated by adding Gaussian white noise with variances of 5, 10,25 and
50. The thresholds for each detector are selected by trial and error for each edge detector. The
performance evaluation is based on visual inspection of the resulting images.
2 Objectives
To implement the following edge detectors:
a.
b.
c.
d.
Roberts
Prewitt
Sobel
Laplacian of Gaussian
To create a dataset consisting of 10 images and adding white gaussian noise of mean 0 and variances
5,10.,15 and 25 to the dataset.
To Test the performance of the edge detectors on the above created datasets.
3 Edge Detection:
An edge, in an image, is a collection of connected high frequency points. Visually, an edge is a region in
an image where there is a sharp change in intensity of the image. Edge detection refers to the
operation(s) performed on an image to detect the edges in an image. The output of edge detection is
usually thresholded to retain only the edge. Edge detection plays a vital role in object detection and
feature extraction and plays pivotal role in machine vision. There are different types of edges – step
edges, roof edges, line edges, colour edges, gray level edges, texture edges etc. Not all edges are
detected by all edge detection operators. Each operation has its specific specialty in edges and better
the edge detection, usually, more complex and costly is the operation.
(a)
(b)
Figure 1 Common edge types: a) Step Edge b) Roof Edge c) Line Edge
(c)
An edge has both magnitude and direction. The direction is used to identify the next possible edge
point. Finally, all the edge points are linked together to form an object boundary. In an ideal scenario, all
edges are connected and we get a perfect boundary, but this is seldom the case due to various reasons
such as difference in illumination, partially visible objects, texture variation, inefficiency of the edge
detection operator etc. Some times, the edge detection operation might even result in false edges. To
resolve these issues, there have been a number of edge detection operators defined throughout the
history of Image Processing. However, no one of them is a panacea for Edge Detection. All the edge
detection methods are based upon the description of ‘changes of continuous functions using
derivatives’ given by calculus. Simply put, all operators are gradient operators.
Gradient edge detectors are those which describe edges by means of partial derivatives. A change in the
image function can be described by a gradient that points in the direction of the largest growth of the
image function. They are of three types [1]:
1. Operators performing derivatives by using differences. Eg: Sobel
2. Operators based on the zero crossings of the second derivatives. Eg: Canny edge detector.
3. Operators that match the image function to a known parametric model of the edges.
Figure 2 Edges and their derivatives
3.1 Roberts Edge Detector
The Roberts edge detector computes the 2-D spatial gradient measurement on an image. It consists of a
pair of 2×2 convolution kernel:
Figure 3 The 2x2 kernel for the Roberts operator. Note that the emphasis is on the diagonal elements
As can be observed, the operator responds to edges running at 45° because of the diagonal weightage of
the values. The gradient magnitude is given by:
And the angle of orientation is given by:
3.2 Sobel Edge Detector
The Sobel edge detector computes the 2-D spatial gradient measurement on an image. It consists of a
pair of 3×3 convolution kernel:
Figure 4 The convolution kernel for the Sobel Edge detector. Note the emphasis on the horizontal and vertical edges
The detector responds maximally to vertical and horizontal edges, as can be observed from the values of
the masking kernel.
The gradient magnitude is given by:
And the angle of orientation is given by:
3.3 Prewitt Edge Detector
This too is a 2D edge detector with a 3x3 kernel. The kernel is almost similar to the Sobel operator
except for the weights assigned to the center pixels. The kernel is shown below:
1
1
1
1
0
-1
0
0
0
1
0
-1
-1
-1
-1
1
0
-1
Gx
Gy
Figure 5 The convolution kernel for the Sobel Edge detector. Note the emphasis on the horizontal and vertical edges
3.4 Laplacian of Gaussian Edge Detector
The Laplacian L(x,y) of an image with pixel intensity values I(x,y) is given by:
As the image is discrete, the convolution kernel needs to be an approximation. A sample 17x17 kernel is
shown in Figure 6.
The 2-D LoG function centered on zero and with Gaussian standard deviation
and can be shown as in Figure 7.
has the form:
Figure 6 The 17x17 Gaussian Kerenel [1]
Figure 7 2-D LoG function centered on zero and with Gaussian standard deviation sigma
As the LOG has a Gaussian smoothing followed by a gradient based edge detector, it performs better
when compared to the other edge detectors in the presence of noise.
4 Dataset
The dataset consists of 10 random gray scale images each of random size. For each image in the dataset,
4 more images are created by adding white Gaussian noise of variance 5,10,25,50. The noise is added by
the imnoise function in Matlab.
a.
b.
c.
d.
e.
f.
g.
h.
i.
j.
Figure 8 Sample images from the dataset a,f: Original images. b,g: white gaussian noise with variance 5 added. c,h: b,g: white
gaussian noise with variance 10 added. d,i: b,g: white gaussian noise with variance 25 added. e,j: b,g: b,g: white gaussian
noise with variance 50 added.
5 Results
5.1 Roberts Edge Detector:
a.
b.
c.
d.
e.
f.
g.
h.
i.
j.
Figure 9 a-e: input images with increasing noise. f-g corresponding output for the image above when passed through the
Roberts Edge Detector
a.
f.
b.
g.
c.
h.
d.
i.
e.
j.
Figure 10 a-e: input images with increasing noise. f-g corresponding output for the image on the left when passed through
the Roberts Edge Detector
5.2 Sobel Edge Detector:
a.
b.
c.
d.
e.
f.
g.
h.
i.
j.
Figure 11 a-e: input images with increasing noise. f-g corresponding output for the image above when passed through the
Sobel Edge Detector
a.
f.
b.
g.
c.
h.
d.
i.
e.
j.
Figure 12 a-e: input images with increasing noise. f-g corresponding output for the image on the left when passed through
the Sobel Edge Detector
5.3 Prewitt Edge Detector:
a.
b.
c.
d.
e.
f.
g.
h.
i.
j.
Figure 13 a-e: input images with increasing noise. f-g corresponding output for the image above when passed through the
Prewitt Edge Detector
a.
f.
b.
g.
c.
h.
d.
i.
e.
j.
Figure 14 a-e: input images with increasing noise. f-g corresponding output for the image on the left when passed through
the Prewitt Edge Detector
5.4 Laplacian of Gaussian Edge Detector:
a.
b.
c.
d.
e.
f.
g.
h.
i.
j.
Figure 15 a-e: input images with increasing noise. f-g corresponding output for the image on the left when passed through
the LoG Edge Detector
a.
f.
b.
g.
c.
h.
d.
i.
e.
j.
Figure 16 a-e: input images with increasing noise. f-g corresponding output for the image on the left when passed through
the LoG Edge Detector
6 Conclusion
As can be clearly seen the Laplacian of Gaussian edge detector clearly outperforms all the other edge
detectors. In the absence of noise, all the detectors perform fairly equally. When the noise is introduced,
though, the Sobel and Prewitt operators fail miserable. This is because of their high sensitivity to high
frequency and the small region of the mask. The Laplacian of Gaussian is successful compared to the
others because of its Gaussian smoothing filter that removes most of the Gaussian noise leaving a much
better operating condition for the Laplacian edge detector. That is the reason why, even with noise of a
variance of 50, the human eye is still able to pick up the edges from the edge detected image.
7 References
[1] R. Jain, R. Kasturi, and B. G. Schunck, Machine Vision (McGraw-Hill, 1995)
[2] Rafael C. Gonzalez, Richard E. Wood "Digital Image Processing", Prentice Hall, 2002
[3] Milan Sonka et all, "Image Processing, Analysis and Machine Vision", PWS, Brooks/Cole, ITP; third
edition
Download