Escolar Documentos
Profissional Documentos
Cultura Documentos
Gradient-based methods
Gradient-based methods are often used to nd edges in images. Consider for example a 1-D function f (x) the derivative f (x) = df dx
takes on values with a large magnitude at the points where the function has a high rate of change. It is reasonable to expect that these points will correspond to edges in the function. The generalisation of f (x) to a 2-D function f (x, y ) is the gradient f (x, y ) = f (x, y ) f (x, y ) ix + iy , x y
where ix and iy are unit vectors in the x and y directions respectively. The magnitude of f (x, y ) is rst computed, and is then compared to a threshold to nd candidate edge points.
Convolution
Since the edge detection process involves comparing the computed derivatives to a threshold that can be adjusted, the scaling factors 1/T and 1/(2T ) can be omitted. This operation is equivalent to calculating edges by forming the convolution product between the function f (n 1 , n2 ) an impulse response of one of the forms
+1
+1
50
50
100
100
150
150
200
200
Noise reduction
Derivatives calculated using the method described are typically quite noisy estimates of f (x, y )/x. This can be improved by averaging the derivative over several samples, for example f (x, y ) [f (n1 + 1, n2 + 1) f (n1 1, n2 + 1)] x + [f (n1 + 1, n2 ) f (n1 1, n2 )] + [f (n1 + 1, n2 1) f (n1 1, n2 1)]. This is equivalent to calculating the horizontal derivative by convolving with the kernel
+1 +1 +1
0 0 0
1 1 1
50
100
150
200
Operation
By the commutative properties of the convolution product we can smooth the image before calculating the derivatives, or calculate smoothed estimates of the derivative. In either case the required quantities can be obtained by convolving with a combined lter impulse response. Thus the dierencing operations described can be viewed as the convolution of f (n1 , n2 ) with the impulse response of a lter h(n1 , n2 ).
Sobel:
In these relationships h1 corresponds to a lter for detecting horizontal edges, and h2 vertical edges. The formulations dier in terms of their properties, and in some cases their computational complexity.
Nondirectional edge detectors can be developed using a discrete approximation to | f (x, y )|, such as | f (x, y )| = f (x, y ) x
2
f (x, y ) y
Clearly this just involves forming some combination of the edges in the horizontal and vertical directions.
Laplacian-based methods
The objective of an edge detection algorithm is to locate regions where the intensity is changing rapidly. For 1-D functions and gradient-based methods, f (x) is considered large when its magnitude |f (x)| is larger than a threshold. Another way is to assume |f (x)| large whenever it reaches a local extremum, or when f (x) has a zero crossing. Declaring zero-crossing points as edges results in a large number of points being declared edge points. Since the magnitude of f (x) is not considered, any small ripple in f (x, y ) generates a detected edge. Due to this sensitivity to noise, the application of noise reduction is a necessary prerequisite.
f (x, y ) =
( f (x, y )) =
2 f (x, y ) 2 f (x, y ) + . x 2 y 2
For a 2-D sequence f (n1 , n2 ) the partial derivatives can be replaced by some form of second-order dierences. As in the case of gradient-based methods, these dierences can be represented by a convolution of f (n1 , n2 ) with the impulse response of a lter h(n1 , n2 ). For example, approximating the derivative by f (x, y ) fx (n1 , n2 ) = f (n1 + 1, n2 ) f (n1 , n2 ), x the term 2 f (x, y )/x 2 can be approximated by 2 f (x, y ) fxx (n1 , n2 ) = fx (n1 , n2 ) fx (n1 1, n2 ) x 2 = f (n1 + 1, n2 ) 2f (n1 , n2 ) + f (n1 1, n2 ).
With the derivatives in the y -direction approximated similarly, the estimate of the Laplacian is
2
f (x, y ) fxx (n1 , n2 ) + fyy (n1 , n2 ) = f (n1 + 1, n2 ) + f (n1 1, n2 ) + f (n1 , n2 + 1) + f (n1 , n2 1) 4f (n1 , n2 ).
50
100
150
200
Laplacian operators
Perception of edges
Do you think that either of the two methods presented coincide with the way we perceive edges?
Edge linking
Obtaining an estimate of the image gradient is only part of the problem in edge detection, where the nal goal is a binary image indicating the presence of edges. There are many dierent ways of linking regions of high gradient into distinct edges.
Thinning
The simplest method is edge thinning, where the gradient is thresholded, and the resulting regions thinned down to single-pixel-wide closed, connected boundaries:
50
50
100
100
150
150
200
200
Hysteresis approach
This invariably leads to gaps in the edges, which often need to be lled to arrive at a useful edge representation. A very eective alternative is to use the Canny approach to edge linking, where (amongst other things) simple hysteresis is used during the linking of high-gradient ridges:
50
100
150
200
Example: Bottles
The methods described can be generalised to estimating the strength of edges in arbitrary specied directions. This was put to good use in a project where the goal was to identify Coca-cola bottles that had defects on the rim:
Estimates of the vertical and horizontal edge gradients are shown below:
It is then a relatively simple matter to identify anomalies in the rim prole. The method was used in an industrial system, and runs in about 15ms on a fast PC.