You are on page 1of 47

An edge is the boundary between an

object and the background, and


indicates the boundary between
overlapping objects.
Edges in images are areas with strong
intensity contrasts a jump in intensity
from one pixel to the next.
significantly reduces the
amount of data
filters out useless information
preserves the important
structural properties
Useful in applications such as:
object detection and recognition
segmentation
tracking
Why edge
detection?
Refraction or poor focus
False edge detection
Missing true edges
Edge localization
High computational time
Problems due to noise

Why not:
The
problems
To do the comparison of various edge
detection techniques and analyze the
performance of the various techniques in
different conditions
PROBLEM:
We have analyzed and did the visual comparison of the
most commonly used Gradient and Laplacian based Edge
Detection techniques for problems of inaccurate edge
detection, missing true edges,
producing thin or thick lines and problems due to noise etc.
The software is developed using MATLAB 7.6.0 (R2008a).
The ability to measure gray-level transitions
in a meaningful way.
(R.C. Gonzales & R. E. Woods Digital
Image Processing)


IDEAL EDGE RAMP EDGE
Gradient: The gradient method detects the
edges by looking for the maximum and
minimum in the first derivative of the image.

Laplacian: The Laplacian method searches
for zero crossings in the second derivative of
the image to find edges. An edge has the one-
dimensional shape of a ramp and calculating
the derivative of the image can highlight its
location.
MARR HILDRETH EDGE DETECTOR
CANNY EDGE DETECTOR
SOBEL EDGE DETECTOR
ROBERTS EDGE DETECTOR
PREWITT EDGE DETECTOR
( )
Detected Edge TRSH
x
y x I
>
c
c ,
( )
x
y x I
c
c ,
TRSH
( ) y x I ,
x x
Original First Derivative
( ) y x I ,
( )
x
y x I
c
c ,
( )
Detected Not Edge TRSH
x
y x I
<
c
c ,
TRSH
Gradient requires computing partial
derivatives:



Since were dealing with digital
quantities , so we use a digital
approximation about a point :




Cross gradient operators
Diagonal edge detection needs 2-D
mask*
Gx = (z9-z5) Gy = (z8-z6)



0 0 0
0 -1 0
0 0 1
0 0 0
0 0 -1
0 1 0
*Masks that are symmetric about the
centre point are more useful for
computing edge detection: smallest one
being 3X3
They take into account nature of data
on opposite sides of the center point
and thus carry more information
regarding the direction of an edge.







Uses 3X3 convolution masks, one estimating
the gradient in x-direction (rows) and the
other in the y-direction (columns).
These approximations are more accurate
than Roberts operators.






-1 -1 -1
0 0 0
1 1 1
-1 0 1
-1 0 1
-1 0 1
( ) ( )
3 2 1 9 8 7
z z z z z z G
x
+ + + + ~ ( ) ( )
7 4 1 9 6 3
z z z z z z G
y
+ + + + ~
A slight variation in Prewitt operators, a
weight of 2 in the center coefficient,
which provides image smoothing.
Performs a 2-D spatial gradient
measurement on an image
Calculates the approximate absolute
gradient magnitude at each point in
input image (which should be in
grayscale)

( ) ( )
3 2 1 9 8 7
2 2 z z z z z z G
x
+ + + + ~
( ) ( )
7 4 1 9 6 3
2 2 z z z z z z G
y
+ + + + ~





Prewitt masks are simpler to implement
than these but Sobel masks have better
noise suppression, which makes them
preferable.*
-1 -2 -1
0 0 0
1 2 1
-1 0 1
-2 0 2
-1 0 1
Prewitt



Sobel
0 1 1
-1 0 1
-1 -1 0
-1 -1 0
-1 0 1
0 1 1
0 1 2
-1 0 1
-2 -1 0
-2 -1 0
-1 0 1
0 1 2
Coefficients of all the masks sum to zero
thus giving a response of zero in uniform
regions(areas of constant intensity)
Computing the magnitude requires
squares and square roots calculations
which are pose computational burden
so an approach which is frequently used
to approximate grad values is

It still preserves relative changes in
intensity levels


The Laplacian of an image highlights
regions of rapid intensity change and is
therefore often used for edge detection.
Its often applied to an image that has first
been smoothed with something
approximating a Gaussian Smoothing filter
in order to reduce its sensitivity to noise*.
It normally takes a single gray level image
as input and produces another gray level
image as output.
Gradient based Operator with use of
Laplacian to take 2
nd
derivative.
Step difference will be represented by a
zero crossing in the 2
nd
derivative as
shown earlier.

1. Smooth the image using a Gaussian. This
smoothing reduces the amount of error
found due to noise.
2. Apply a two dimensional Laplacian to
the image:

This operation is the equivalent of taking the second
derivative of the image.

This Laplacian will be rotation invariant and is often
called the Mexican Hat operator because of its
shape.

3. Loop through Laplacian and look for sign changes.
If there is a sign change and the slope across this sign
change is greater than some threshold, mark this
pixel as an edge.
Since both the Gaussian and the
Laplacian kernels are usually much
smaller than the image, this method
usually requires far fewer arithmetic
operations.
The LoG (Laplacian of Gaussian)
kernel can be pre-calculated in
advance so only one convolution needs
to be performed at run-time on the
image.
Created by John
Canny for his
Masters thesis at
MIT in 1983 [2], and
still outperforms
many of the newer
algorithms that
have been
developed.
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.*
A third criterion is to have only one
response to a single edge*.
STEP-1. Smooth the image with a two
dimensional Gaussian. In most cases the
computation of a two dimensional
Gaussian is costly, so it is approximated
by two one dimensional Gaussians*, one
in the x-direction and the other in the y-
direction.
2. Take the gradient of the image. This
shows changes in intensity, and highlights
regions with high spatial derivatives,
which indicate the presence of
edges.*Calculate the approx. magnitude
or edge strength:

The direction is computed:
=arctan(gy/gx)
{Exception for gx=0 case:
=0 if gy=0
o
& =90
o
if gy0}



Next comes resolving the edge
orientation into one of the four possible
direction in a matrix:
the edge orientation has to be resolved
into one of these four directions
depending on which direction it is closest
to (e.g. if the orientation angle is found
to be 3
o
, make it 0
o
).
Color range & set
value
Orientation
Yellow - 0
o
0
o
to 22.5
o
&
157.5
o
to 180
o

Green 45
o
22.5
o
to 67.5
o

Blue 90
o
67.5
o
to 112.5
o

Red 135
o
112.5
o
to 157.5
o

3. Non maximal suppression: Edges will
occur at points the where the gradient is
at a maximum. Therefore, all points not
at a maximum should be suppressed.

Trace along the edge in the edge
direction and suppress any pixel value
(set it equal to 0) that is not considered
to be an edge.
This will give a thin line in the output
image.

4. Hysteresis: Edge Thresholding *: It is
used to eliminate streaking.
Streaking is the breaking up of an edge
contour caused by the operator output
fluctuating above and below the
threshold.
It makes use of both a high threshold
and a low threshold.
Pixel value and position Set as edge or not
Pixel value Above high threshold Yes
Pixel value below low threshold No
Pixel value above low threshold AND a neighbor
pixel is set as edge
Yes
Pixel value above low threshold AND None of
the neighbors is an edge pixel
No


Image File
MATLAB


Display
Edge
Detection
Threshold :specifies the sensitivity
threshold for the Laplacian of Gaussian
method.
Sigma: is the standard deviation of the
LoG filter. The default sigma is 2; the size
of the filter is nXn, where n =
ceil(sigma*3)*2+1.
Threshold: specifies sensitivity thresholds for
the Canny method. thresh is a 2-element
vector in which the 1is the low threshold,
and the 2 is the high threshold. If you
specify a scalar for thresh, this value is used
for the high threshold and 0.4*thresh is used
for the low threshold.
Sigma: is the standard deviation of the
Gaussian filter. The default sigma is 1; the
size of the filter is chosen automatically,
based on sigma.
One test image was artificial and the
other was a real world photograph.
All color images were converted to
grayscale using Matlabs RBG2GRAY
function.
Various threshold, sigma, slope, etc.
values were chosen by hand.
High threshold for Canny = 0.15 and
lower threshold=0.4*0.15
Edge detection of all five types was
performed on wheel.jpg. Canny yielded the
best results.
Canny yields thin lines for its edges by using
non-maximal suppression. Canny also
utilizes hysteresis with thresholding.
Second order derivative tests yield better
results than first order derivatives
If hysteresis is used with LoG operator, results
would be close to Canny method.
edge_detection1.m
for Marr Hildreth Operator with
threshold=0: If a threshold of 0 is
specified, the output image has closed
contours, because it includes all the zero
crossings in the input image.
Cannys method is still preferred since it
produces single pixel thick, continuous
edges.
edge_detection2.m

Motion blur was applied to wheel.jpg
Four edge detection methods: Prewitt,
Sobel, Roberts and Canny were utilized.

No method appeared to be useful for
real world applications. However, Canny
produced the best the results out of the
set.
edge_detection3.m
Gaussian blur was applied to wheel.jpg
The edge detection methods previously
used were utilized again on this new image.
No method appeared to be useful for real
world applications. This was expected as
Gaussian noise corrupts edges and image
detail making it difficult to distinguish clear
regions in an image.
edge_detection4.m
Gaussian blur was applied to wheel.jpg. Then,
a 3x3 average filter was applied to this image.
No method appeared to be useful for real
world applications.
However, Prewitt and Sobel were the most
affective out of the set. This was because these
filters have a larger mask size than Roberts and
thus can show gradient information over a
larger area.
This is useful because image averaging spreads
each pixels information over an area larger
than one pixel, in this case a 3x3 area.
edge_detection5.m
We studied Canny, Marr Hildreth, Roberts, Sobel,
and Prewitt edge detection masks.

Noise can affect the results of these edge detection
algorithms. In environments where edge detection is used,
motion blur is often a problem.
For non noisy images, Canny appeared to work the best.
In noisy environments, Prewitt or Sobel yield best results
after an average filter is applied. However, these results
appeared to not be very useful in real-world applications.
In motion blurry environments, Canny seemed to be the
most affective of the four filters. However, the results it
produced would be hard to utilize in a real world
environment.

Canny algorithm is adaptable to various environments
- Real time implementations in DSPs or FPGAs
- Fast embedded PCs

Edge detection algorithms have been modified in
many ways to solve multiple problems like:

- Feature extraction: chin contour estimation.
A modified canny edge detector to detect the
potential chin edges, that is edges connected
together to form a continuous form.
- Removing facial blemishes.
The program would remove them and fill them in with
a value that would render the removed blemish
undetectable to the human eye
As a conclusion, we usually use the edge
detectors in some of these fields, which
are highly interrelated :
Computer vision
Digital image processing
Feature extraction
Edge detection
Scale space
[1] Canny, John, "A Computational Approach to Edge
Detection," IEEE Transactions on Pattern Analysis and
Machine Intelligence,Vol. PAMI-8, No. 6, 1986, pp. 679-698.
[2] Lim, Jae S., Two-Dimensional Signal and Image Processing,
Englewood Cliffs, NJ, Prentice Hall, 1990, pp. 478-488.
[3] Parker, James R., Algorithms for Image Processing and
Computer Vision, New York, John Wiley & Sons, Inc., 1997,
pp. 23-29.
[4] Gonzalez R.C., Woods R.E., Digital Image Processing, Third
Edition, Prentice Hall, 2009.
[5] W. E. Grimson and E. C. Hildreth. Comments on Digital
step edges from zero crossings of second directional
derivatives. IEEE Trans. Pattern Anal. Machine Intell., vol.
PAMI-7, no. 1, pp. 121-129, 1985

[6] Nadernejad E., Edge Detection Techniques:
Evaluations and Comparisons, Applied Mathematical
Sciences, Vol. 2, 2008, no. 31, 1507 1520
[7] R. Owens, "Lecture 6", Computer Vision IT412,
10/29/1997.
http://homepages.inf.ed.ac.uk/rbf/CVonline/LOCAL_COPIES/OWENS/LE
CT6/node2.html
[8] S. Price, "Edges: The Canny Edge Detector", July 4, 1996.
http://homepages.inf.ed.ac.uk/rbf/CVonline/LOCAL_COPIES/MARBLE/lo
w/edges/canny.html
[9] Seventh International Conference on
Control,Automation, Robotics and Vision
(ICARCV02),Dec 2002, Singapore. Chin Contour
Estimation Using Modified Canny Edge Detector.

You might also like