Professional Documents
Culture Documents
0
1
and
Gy
00
10
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 matrixs 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 Detecton
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
101
101
101
ANDGy
1 1 1
000
111
(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 Detecton
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 filters 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
.e
( x
2
+y
2
)
2
2
LoG filter detects misplaced edges due to the
blurring effect on the image caused by the
filters 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 images 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)
ORGNAL MAGE
MARR EDGE DETECTION
ROBERTS EDGE DETECTION
SOBEL EDGE DETECTION
PREWTT 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,
editr), NY, Academic Pres. (1970)
[4] GONZALEZ, R. VE WINTZ, P,,DGTAL
IMAGE PROCESSNG, ADDSON-
WESLEY,(1987)
[5] PREWITT.PCTURE PROCESSNG AND
PSYCHOPCTORCS, NY, ACADEMC 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 DETECTON
INTELLGENCE LABORATORY. MT
SEPTEMBER (1985)