You are on page 1of 26

ABSTRACT

In this study, edge detection methods are
investigated. Firstly, literature review has been
done. A variety of
methods are studied and most important ones
such as Sobel, Roberts, Marr- Hildreth, and
Prewitt are thoroughly studied
For each of them, matlab codes are created and
these codes' results are displayed with pictures.
INTRODUCTION
The system that consists of screening and
screen analysis methods have a great variety of
implementation area. In 1970s, when image
processing methods were first developed, it
made image processing difficult because of the
place that images occupy. The first systems
used special tools in order to process a large
amount of data. From 1990, with the invention of
personal computers, image processing systems
popularized. The process of edge finding was
generally used as to detect the objects, and
image improving and image zipping, so it was
crucial to process these processes quick. In
this project, I described what edge detection is,
the methods of edge detection and where it can
be used. At the same time, I showed the mat lab
codes for methods and how these codes were
used on pictures.

Chapter 1:Edge Detection and Local Edge
Algorithms
Chapter 2:Method of edge Detection
Chapter 3: Conclusion for this project

1.EDGE DETECTİON

Edges are sudden variances at the pixel value
among the smooth area. The main purpose of
Edge sensing reveals the area of the sudden
variances. [1]. There is a definition in the
literature as kitchen and Rosenfold said that "
This is a border of two area that every area has
homogen itself, but there are different each
other in a few ways.''[2]…According to the
definition, It can be said that the purpose of
Edge sensing is actually sensing of light edges.

A lot of Geometrics and optics features cause
becoming Edges in an image..

Geometric features of Edges specifying;
a-) Borders of object
b-) Discontinuities of Surface orientation and
Color's tissue
c-) This a tissue and color differences which
come out of two objects seem like one on the
top of the other.

Features of Edges Creating;

1-) Light’s reflection directly
2-) The Shadow which is formed the part of an
object, or The shadow which is formed the other
objects.
3-) The reflection of the same object or the
intermediary reflection of the other objects
4-) Variances of Tissue and Color.

We can say that generally, there are Edge
sensing's algorithm of Prewitt, Sobel ,Roberts,
Marr and hilldreth. These are common usage
algorithm..

1.2 Local Edge Algorithms

An image can be expressed as a discontinuous
function of two variables (x, y). Process of edge
detection determines the sudden changes in the
magnitude of this function. Therefore, first and
second order derivatives can be deployed to
detect the edges on the image. Some of the
basic edge detectors are actually convolution
matrices which take derivative of the image
function [3].

Gradients are used to compute derivatives. For
a 2-dimension function, gradients provide
information on the direction of discontinuities
along with derivatives. Magnitude of the
gradient determines whether the point is an
edge or not while angle of the gradient provides
the direction of the edge. Given f(x,y) as the
continuous image function, gradient vector of
the image density can be derived as follows:




Vector of gradient magnitude and direction



If , vector of gradient for cutting an
image



Convolution of this equation





Is calculated.
I’m going to explain edge detection method
2.METHODS OF EDGE DETECTİON
2.1.Roberts Edge Detectıon:
It takes a 2x2 frame over the original image and
calculates an approximate gradient vector. [4]
Calculated gradient vector's sizes, in the image
size if put on a pixel's matrix, an image were
perceived that shows the edges of the original
image.
İf
f (x, y)
is continuous image function,
gradient vector of image intensity.


g f (x, y) · f (x, y) f (x +1, y +1)
2
+ f (x +1, y) f (x, y+1)
2
}
1/2
{

Horizontal and vertical direction convolution
mask;

Gx ·
1
0

  
0
1

and
Gy ·
0 0
1  0

Since Roberts edge detection operators are size
of 2x2, computed gradient values are
approximate. Different from odd-sized
operators, computed gradient is placed on f
(x,y), instead of the matrix’s center. This way,
approximate gradient point is matched on the
original image. This image, which consists of
edges obtained by convolving 2x2 sized
horizontal and vertical matrices on the original
image, is actually an the iterated collection of
the edges which belong to the original input. It
is difficult to remove the iteration effect since
the magnitudes of iterations are related to
direction of discontinuities.


original image
Roberts Operator

2.2. Prewitt Edge Detectıon
This edge detection computes the gradient of
each point of the input. Magnitudes of gradients
constitute the edge-improved image. Direction
of edge is determined by gradient angle [5].
Gradient is computed by convolving one
vertical and one horizontal matrix on the
original image. Matrices are obtained by
differential equations of first order. First order
derivative of f (x) is obtained by Taylor Series
expansion. Taylor Series expansion of f (x) in
the neighborhood of x=a is expressed as:

f (x) · f (a) + f (a)(x a) +
f (a)(x a)
2
2!
+
f (a)(x a)
3
3!
+....(2.1)


Making use of this equation, expansion of f
(x+dx), …

f (x + D x) · f (x) + D x ¢ f (x) +
(D x)
2
2!
¢¢ f () +.....    (2.2)

İf this equation arrange repeat,

f (x + D x) - f (x)
D x
· ¢ f (x) +
D x
2!
¢ f (x)+........   (2.3)

Making use of this equation, expansion of f (x-
dx), …

f (x - D x) · f (x) - D x ¢ f (x) +
(D x)
2
2!
¢¢ f (x) - ......    (2.4)

When f (x+dx) and f (x-dx) subtract from each
others


f (x + D x) - f (x - D x) · 2D x ¢ f (x) +
2(D x)
3
3!
¢¢ f (x) +......     (2.5)
f (x + D x) - f (x - D x)
2D x
· ¢ f (x) +
(D x)
2
3!
¢¢ f (x) +...     (2.6)



Then, When we take the first derivative...




Two equations above provide the gradient
magnitudes for x and y-axes. When difference
among pixels are set to dx=dy=1 in this
expression, expanding the coefficients in the
derivatives to obtain 3x3 convolution matrices
results in following Prewitt convolution
matrices:

¶f
¶x
·
f (x + D x, y) - f (x, y)
D x
·
f (x + D x, y) - f (x - D x, y)
2D x
   (2.7)
¶f
¶y
·
f (x, y + D y) - f (x, y)
D y
·
f (x, y + D y) - f (x, y - D y)
2D y
    (2.8)

Gx ·
1  0  1
1  0  1
1  0  1

    AND  Gy ·
1   1   1
0     0    0
1      1     1

     (2.9)

Matlab code 1;
im=imread('cameraman.tif');
[row col]=size(im);
a=double(im);
subplot(3,2,1);
imshow(im);
title('Original image');
gx=[-1 0 1;-1 0 1;-1 0 1];
gy=[-1 -1 -1;0 0 0;1 1 1];
for i=2:row-1
for j=2:col-1
fx (i, j)=a (i-1, j-1)*gx (1)+a(i-1,j)*gx(2)+a(i-
1,j+1)*gx(3)+a(i,j-1)*gx(4)+
a (i, j)*gx (5)+a(i,j+1)*gx (6)+a(i+1,j-
1)*gx(7)+a (i+1,j)*gx(8)+a(i+1,j+1)*gx(9);
end
end
subplot (3,2,2);
imshow(uint8(fx));
title('X-Gradient');
for i=2:row-1
for j=2:col-1
fy(i,j)=a(i-1,j-1)*gy(1)+a(i-1,j)*gy(2)+a(i-
1,j+1)*gy(3)+a(i,j-1)*gy(4)+
a(i,j)*gy(5)+a(i,j+1)*gy(6)+a(i+1,j-
1)*gy(7)+a(i+1,j)*gy(8)+a(i+1,j+1)*gy(9);
end
end
subplot(3,2,3);
imshow(uint8(fy));
title('Y-Gradient');
F=fx+fy;
Subplot(3,2,4);
imshow(uint8(F));
title ('Edge detected using prewitt algo');



Matlab code 2:
I = imread('tire.tif');
BW1 = edge(I,'prewitt');
BW2 = edge(I,'canny');
imshow(BW1);
figure, imshow(BW2);
figure,imshow(I)

2.3. Sobel Edge Detectıon

The motivation behind Sobel edge detector is to
find a more efficient computation method
compared to widely used methods such as
Robert algorithm, by computing more direction-
independent gradients [6]. It is based on
computing the gradient magnitude of a point on
the image (which is treated as a function) by
vector sum of gradients on four central
directions in the 3x3 vicinity of the point of
interest. This approach makes up the Sobel
Edge Detector.


( ) ( ) ( )

( ) ( ) ( )

( ) ( ) ( )



Vector sums of these gradients give the average
value on the directions of measurement. If
function at a particular point is actually planar,
all points in the neighborhood have the same
gradient value.
Gradient of the central point for a 3x3
neighborhood is found by adding up
perpendicular vector pairs. Gradient vectors
used for this purpose are shown in Figure 3.1,
(I, j) being the central point.
Each perpendicular vector is computed after
multiplying the directional unit vector by
magnitude of the directional derivative.




a b c
d e f
g h I
(3.2):33 placement of pixels for neighborhood


Vector sum of four gradients is the same as
vector sum of eight directional derivative
vectors. A central point and density values of its
8x8 neighborhood is shown in Figure (3.2). For
the given neighborhood; given yf as difference
of density and k as distance between
neighbors; magnitude of directional derivative
vector, g is expressed by:

||

Grouping the corresponding points as (a,i),
(b,h), (c,g) and (f,d); vector sum of gradients for
R= (√) (R being the distance of pixels on
diagonals to central point), is equal to



( )

[ ]

( )

[ ]

( ) [ ]
( ) [ ]



As a result of this equation;

[(

) (

)
]

Multiply 2;

́
[( )
( ) ( ) ( )]


-1 0 1
-2 0 2



Figure (3.7) horizontal and vertical direction of
weight coefficient





Matlab code ;

im=imread('cameraman.tif');
[row col]=size(im);
a=double (im);
Subplot(3,2,1);
imshow(im);
title('Orijinal image');
gx=[-1 0 1;-2 0 2;-1 0 1];
gy=[-1 -2 -1;0 0 0;1 2 1];
%X-gradient
for i=2:row-1
for j=2:col-1
fx(i,j)=a(i-1,j-1)*gx(1)+a(i-1,j)*gx(2)+a(i-
1,j+1)*gx(3)+a(i,j-1)*gx(4)+
a (i,j)*gx(5)+a(i,j+1)*gx(6)+a(i+1,j-
1)*gx(7)+a(i+1,j)*gx(8)+a(i+1,j+1)*gx(9);
End
End
Subplot (3,2,2);
imshow(uint8(fx));
title('X-Gradient');
%Y-gradient
-1 0 1
1 2 1
0

0 0
-1 -2 -1
for i=2:row-1
for j=2:col-1
fy(i,j)=a(i-1,j-1)*gy(1)+a(i-1,j)*gy(2)+a(i-
1,j+1)*gy(3)+a(i,j-1)*gy(4)+
a(i,j)*gy(5)+a(i,j+1)*gy(6)+a(i+1,j-
1)*gy(7)+a(i+1,j)*gy(8)+a(i+1,j+1)*gy(9);
End
End
Subplot (3,2,3);
imshow(uint8(fy));
title('Y-Gradient');
F=fx+fy;
Subplot (3,2,4);
imshow(uint8(F));
Title ('Edge detected using sobel algo')







2.4.Marr-Hildreth Edge Detection

In 1980, Marr and Hildreth developed an edge
detecting algorithm by improving the work of
Marr and Poggio from 1979. This algorithm is
based on Gauss filtering followed by Laplace
operation, that is, convolving the input with
Laplacion of the Gaussian filter; therefore this
method is also known as Laplacian of Gaussian.
Sometimes it is also referred to as “Mexican
Hat” due to the shape of filter’s frequency
response.

Once high frequency components are
eliminated by Gaussian filter, zero-crossing
points are determined by Laplace operation.
Laplacian of Gaussian (LoG) method can be
expressed as:



h(x, y) · Ñ
2
g(x, y)* f (x, y)
[ ]
· Ñ
2
g(x, y)
é
ë
ù
û
* f (x, y)     (4.1)
Ñ
2
g(x, y) ·
x
2
+ y
2
- 2
2

4
æ
è
ç
ö
ø
÷
.e
( x
2
+y
2
)
2
2


LoG filter detects misplaced edges due to the
blurring effect on the image caused by the
filter’s Gaussian component. Consequently,
pale edges which actually exist on the original
image might not be observed on filtered image.
This constitutes the biggest drawback of LoG
method [7]. Reason for this drawback is the fact
that LoG detects local maxima and minima of
input image’s first order derivative to determine
edges, while the actual edges occur on the local
maxima of the original image.


Image of “pepper” after applying LoG is shown
in Figure (4.2). Compared to other edge
detection methods, some edges and details of
the original image might be lost while using this
algorithm.







Original image
LoG
Edge detection figure (4.2)








ORİGİNAL İMAGE


MARR EDGE DETECTION






ROBERTS EDGE DETECTION








SOBEL EDGE DETECTION





PREWİTT EDGE DETECTION






CONCLUSIONS

This study, edge detection methods are
investigated. It is emphasized how these methods
can be used. Roberts edge detection uses 2*2
matrix by circulating on the original image.
Whereas, Sobel method compared to Robert, is
more independent calculating gradient. Sobel and
Prewitt's results are so close to each other. Marr
and Hildreth edge detection are different from the
others because this method concludes by using
gauss filtering and then laplas application.








REFERENCE


[1] ZIOU, D. and TABBONE, S., Edge
Detection Techniques – An Overview, Technical
Report, No.195, Dept.Math & Informatique,
universit de Sherbrooke (1997)
[2] KITCHEN, L.J. and ROSENFELD, A., Edge
Evaluation using local Edge coherence,IEEE
trans.System Man and Cybernetic(1981)
[3] PREWITT, J., Object Enhancement and
Extraction, Picture Processing and
Psychopictorics (B.Lipkin and A.Rosenfeld,
editör), NY, Academic Pres. (1970)
[4] GONZALEZ, R. VE WINTZ, P,,DİGİTAL
IMAGE PROCESSİNG, ADDİSON-
WESLEY,(1987)
[5] PREWITT.PİCTURE PROCESSİNG AND
PSYCHOPİCTORİCS, NY, ACADEMİC PRES
(1970)
[6] SOBEL, I., An Isotropic 33 Gradient
Operator, Machine Vision for three Dimensional
Scenes, Freeman, H., Academic Pres. , NY, 376-
379(1990)
[7]: HILDRETH, E.C.EDGE DETECTİON
INTELLİGENCE LABORATORY. MİT
SEPTEMBER (1985)