Edge Detection and Linking
Edge Detection and Linking
-1 -2 -1 -1 0 1
0 0 0 -2 0 2
1 2 1 -1 0 1
Diagonal mask:
Prewitts
Sobel
Second order derivative masks
• Laplacian is sensitive to noise and it produces
double edges
• It is useful when combined with smoothing.
Laplacian filter
Differentiation measures the rate of change of a
Images taken from Gonzalez & Woods, Digital Image Processing (2002)
function
Let’s consider a simple 1 dimensional example
Images taken from Gonzalez & Woods, Digital Image Processing (2002)
Spatial Differentiation
A
B
1st Derivative
The formula for the 1st derivative of a function is
as follo w s:
f
f (x 1) f (x)
x
5 5 4 3 2 1 0 0 0 6 0 0 0 0 1 3 1 0 0 0 0 7 7 7 7
Applying the formula
0 -1 -1 -1 -1 0 0 6 -6 0 0 10 2 -2 -1 0 0 0 7 0 0 0
8
0 -1 -1 -1 -1 -1 0 0 6 -6 0 0 0 1 2 -2 -1 0 0 7 0 0
6
0 0
4
2
0
-2
-4
-6
-8
It sharpens edges
First order derivative generally produces thicker edges
in an image.
Second order derivative give stronger response to fine
details such as thin lines and isolated points
First order derivative have stronger response to
grey level step
Second order derivative produce a double response at
step edges
2nd Derivative
The formula for the 2nd derivative of a function is
as fo lo2w s:
f
f (x 1) f (x 1) 2 f
x
2
(x)
Simply takes into account the values both before
and after the current value
8
2nd Derivative (cont…)
7
6
5
4
3
2
1
0
5 5 4 3 2 1 0 0 0 6 0 0 0 0 1 3 1 0 0 0 0 7 7 7 7
first derivative 0 -1 -1 -1 -1 0 0 6 -6 0 0 0 1 0 0 7 0 0 0
second derivative
-1 0 0 0 0 1 0 6 -12 6 0 0 1 1 -4 1 1 0 0 7 -7 0 0
2 -2 -1 0
10
-5
-10
-15
Point detection
• An isolated point is a point whose grey level is
significantly different from its background in a
homogeneous area.
Point detection
• The mask is superimposed onto a image and the
convolution process is applied.
• Response of the mask is given as
Mask Image
Matrix
= -1*z1-1*z2-1*z3:2*z4+2*z5+2*z6-1*z7-
1*z8- 1*z9
• For line detection apply all the 4 masks on the
image.
• If the above condition is satisfied, the
corresponding point is more associated with
the line with the corresponding mask i.
Aliter: Line Detection
• R(x, y) = max(|R1(x, y)|, |R2(x, y)|, |R3(x, y)|,
|R4(x, y)|)
Aliter
Prewitt Operator
calculate the resulting new p5 pixel is pixel = (p1+p2+p3-p7-p8- p9)+
(p3+p6+p9-p1-p4-p7)
Prewitts gradient = SQRT((X*X)+(Y*Y))
where X = (p1+p2+p3-p7-p8-p9) and Y = (p3+p6+p9-p1-p4-p7)
Sobel Operator