Edge Detection
Edge Detection
Denition of edges
- Edges are signicant local changes of intensity in an image. - Edges typically occur on the boundary between two different regions in an image.
-2-
Edge descriptors
Edge normal: unit vector in the direction of maximum intensity change. Edge direction: unit vector to perpendicular to the edge normal. Edge position or center: the image position at which the edge is located. Edge strength: related to the local image contrast along the normal.
-3-
Ramp edge: a step edge where the intensity change is not instantaneous but occur over a nite distance. Ridge edge: the image intensity abruptly changes value but then returns to the starting value within some short distance (generated usually by lines).
-4Roof edge: a ridge edge where the intensity change is not instantaneous but occur over a nite distance (generated usually by the intersection of surfaces).
-5-
-6-
h>0
h>0
[1
1]
f(x) = f(x-1)-2f(x)+f(x+1)
(approximates f() at x)
zero-crossing
-8-
magn( f ) =
f 2 f 2 M x2 + M y2 ) +( ) = y x
dir ( f ) = tan1 ( M y / M x )
-9-
x+h
f = f (i , j + 1) f (i , j ) x f f = f (i 1, j ) f (i , j ) or = f (i , j ) f (i + 1, j ) y y
I = z6 z5, x
I = z5 z8 y
- We can implement
-11-
- The partial derivatives can be computed by: M x = ( a2 + ca3 + a4 ) ( a0 + ca7 + a6 ) M y = ( a6 + ca5 + a4 ) ( a0 + ca1 + a2 ) - The constant c implies the emphasis given to pixels closer to the center of the mask. - Setting c = 1, we get the Prewitt operator: 1 M x = 1 1 0 0 0 1 1 1 1 1 1 My = 0 0 0 1 1 1
-12-
-13-
-14-
-15-
-16-
-17- (3) Edge thinning and linking are required to obtain good contours.
-18-
G ( x , y ) is the Gaussian function G x ( x , y ) is the derivate of G ( x , y ) with respect to x : G x ( x , y ) = G y ( x , y ) is the derivate of G ( x , y ) with respect to y : G y ( x , y ) = 2. Compute the gradient magnitude magn(i , j ) = f x2 + f y2 3. Apply non-maxima suppression. 4. Apply hysteresis thresholding/edge linking. x
G ( x , y) G ( x , y)
-19-
Non-maxima suppression
- To nd the edge points, we need to nd the local maxima of the gradient magnitude. - Broad ridges must be thinned so that only the magnitudes at the points of greatest local change remain. - All values along the direction of the gradient that are not peak values of a ridge are suppressed.
magn(i1,j1) 6 6 4 5 7 magn(i,j)
5 5
10 12 16 14 10 11 13 4 4 3 3 5 2 5
magn(i2,j2)
direction of gradient
Algorithm For each pixel (x,y) do: if magn(i , j ) < magn(i 1 , j 1 ) or magn(i , j ) < magn(i 2 , j 2 ) then I N (i , j ) = 0 else I N (i , j ) = magn(i , j )
-20-
-21-
-22-
-23-
- There are two operators in 2D that correspond to the second derivative: * Laplacian * Second directional derivative
The Laplacian
2 f 2 f f = + y2 x2
2
- Approximating 2 f : 2 f = f (i , j + 1) 2 f (i , j ) + f (i , j 1) x2 2 f = f (i + 1, j ) 2 f (i , j ) + f (i 1, j ) y2 2 f = 4 f (i , j ) + f (i , j + 1) + f (i , j 1) + f (i + 1, j ) + f (i 1, j )
-24Example:
Z1 Z2 Z4 Z7 Z5 Z8
Z3 Z6 Z9
2 f = 4 z 5 + ( z 2 + z 4 + z 6 + z 8 )
0 1 0
1 -4 1
0 1 0
Example:
-25-
x 2 + y2 2 2
r2
) e r
/2
, (r 2 = x 2 + y 2 )
-26-
-27-
-28-
- For many applications, it is desirable to be able to process an image at multiple scales. - We determine which edges are most signicant in terms of the range of scales over which they are observed to occur.
-29-