0% found this document useful (0 votes)
45 views

Edge Detection

The document provides an overview of edge detection techniques in computer vision. It defines edges as significant intensity changes in images that typically occur at boundaries between regions. The goals of edge detection are to produce line drawings from images and extract important features like corners, lines and curves. Various edge detection approaches are described, including using derivatives to detect intensity changes, gradient-based methods like Roberts, Prewitt and Sobel, and the Canny edge detector, which optimizes for noise suppression and localization. Key steps involve smoothing, enhancing, detecting and localizing edges.

Uploaded by

Ari Sutarto
Copyright
© Attribution Non-Commercial (BY-NC)
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
45 views

Edge Detection

The document provides an overview of edge detection techniques in computer vision. It defines edges as significant intensity changes in images that typically occur at boundaries between regions. The goals of edge detection are to produce line drawings from images and extract important features like corners, lines and curves. Various edge detection approaches are described, including using derivatives to detect intensity changes, gradient-based methods like Roberts, Prewitt and Sobel, and the Canny edge detector, which optimizes for noise suppression and localization. Key steps involve smoothing, enhancing, detecting and localizing edges.

Uploaded by

Ari Sutarto
Copyright
© Attribution Non-Commercial (BY-NC)
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 29

Edge detection

(Trucco, Chapt 4 AND Jain et al., Chapt 5)

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.

Goal of edge detection


- Produce a line drawing of a scene from an image of that scene. - Important features can be extracted from the edges of an image (e.g., corners, lines, curves). - These features are used by higher-level computer vision algorithms (e.g., recognition).

-2-

What causes intensity changes?


- Various physical events cause intensity changes. - Geometric events * object boundary (discontinuity in depth and/or surface color and texture) * surface boundary (discontinuity in surface orientation and/or surface color and texture) - Non-geometric events * specularity (direct reection of light, such as a mirror) * shadows (from other objects or from the same object) * inter-reections

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-

Modeling intensity changes


- Edges can be modeled according to their intensity proles. Step edge: the image intensity abruptly changes from one value to one side of the discontinuity to a different value on the opposite side.

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).

The four steps of edge detection


(1) Smoothing: suppress as much noise as possible, without destroying the true edges. (2) Enhancement: apply a lter to enhance the quality of the edges in the image (sharpening). (3) Detection: determine which edge pixels should be discarded as noise and which should be retained (usually, thresholding provides the criterion used for detection). (4) Localization: determine the exact location of an edge (sub-pixel resolution might be required for some applications, that is, estimate the location of an edge to better than the spacing between pixels). Edge thinning and linking are usually required in this step.

-5-

Edge detection using derivatives


- Calculus describes changes of continuous functions using derivatives. - An image is a 2D function, so operators describing edges are expressed using partial derivatives. - Points which lie on an edge can be detected by: (1) detecting local maxima or minima of the rst derivative (2) detecting the zero-crossing of the second derivative

-6-

Differencing 1D signals (see also Trucco, Appendix A.2)


- To compute the derivative of a signal, we approximate the derivative by nite differences: Computing the 1st derivative: f ( x ) = lim f ( x + h) f ( x ) f ( x + 1) f ( x ) ( h=1) h mask: [ 1 1] 0 1 ] (centered about x ):

h>0

- Examples using the edge models and the mask [ 1

-7Computing the 2nd derivative: f ( x ) = lim f ( x + h) f ( x ) f ( x + 1) f ( x ) = h

h>0

f ( x + 2) 2 f ( x + 1) + f ( x ) ( h=1) - This approximation is centered about x + 1; by replacing x + 1 by x we obtain: f ( x ) f ( x + 1) 2 f ( x ) + f ( x 1) mask:


20 20 20 20 f(x)

[1

1]

10 10 10 10 10 0 0 0 0 0 0 10 0 0 10 -10 0 0 0 0 f(x) = f(x+1) - f(x)


(approximates f() at x+1/2)

f(x) = f(x-1)-2f(x)+f(x+1)

(approximates f() at x)

zero-crossing

- Examples using the edge models:

-8-

Edge detection using the gradient


Denition of the gradient - The gradient is a vector which has certain magnitude and direction:
f = f x f y

magn( f ) =

f 2 f 2 M x2 + M y2 ) +( ) = y x

dir ( f ) = tan1 ( M y / M x )

- To save computations, the magnitude of gradient is usually approximated by:


magn( f ) | M x | + | M y |

Properties of the gradient


- The magnitude of gradient provides information about the strength of the edge. - The direction of gradient is always perpendicular to the direction of the edge (the edge direction is rotated with respect to the gradient direction by -90 degrees).

-9-

Estimating the gradient with nite differences


f f ( x + h, y) f ( x , y) = lim x h>0 h f ( x , y + h) f ( x , y) f = lim y h>0 h - The gradient can be approximated by nite differences: f ( x + h x , y) f ( x , y) f = = f ( x + 1, y ) f ( x , y ), ( h x =1) hy x f ( x , y + h y ) f ( x , y) f = = f ( x , y + 1) f ( x , y ), ( h y =1) hy y - Using pixel-coordinate notation (remember: j corresponds to the x direction and i to the negative y direction):

x-h y+h y y-h

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

-10Example Suppose we want to approximate the gradient magnitude at z 5


Z1 Z2 Z4 Z7 Z5 Z8 Z3 Z6 Z9

I = z6 z5, x

I = z5 z8 y

magn( I ) = ( z 6 z 5 )2 + ( z 5 z 8 )2 I I and using the following masks: y x


1 -1 1 -1

- We can implement

(note: M x is the approximation at (i , j + 1/2) and M y is the approximation at (i + 1/2, j ))

-11-

The Roberts edge detector


f = f (i , j ) f (i + 1, j + 1) x f = f (i + 1, j ) f (i , j + 1) y - This approximation can be implemented by the following masks: 1 0 Mx = 0 1 0 My = 1 1 0

(note: M x and M y are is approximations at (i + 1/2, j + 1/2))

The Prewitt edge detector


- Consider the arrangement of pixels about the pixel (i , j ): a0 a7 a6 a1 [i , j ] a5 a2 a3 a4

- 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

(note: M x and M y are approximations at (i , j ))

-12-

The Sobel edge detector


- Setting c = 2, we get the Sobel operator: 1 M x = 2 1 0 0 0 1 2 1 1 2 1 My = 0 0 0 2 1 1

(note: M x and M y are approximations at (i , j ))

Main steps in edge detection using masks


( x , y ) = f ( x , y ) * G ( x , y )) (1) Smooth the input image ( f x = f ( x , y) * M x ( x , y) (2) f y = f ( x , y) * M y ( x , y) (3) f y | x | + | f (4) magn( x , y ) = | f x ) y / f (5) dir ( x , y ) = tan1 ( f (6) If magn( x , y ) > T , then possible edge point

(an example using the Prewitt edge detector - dont divide by 2)

-13-

(with noise ltering)

-14-

(without noise ltering)

-15-

Isotropic property of gradient magnitude


- The magnitude of gradient is an isotropical operator (it detects edges in any direction !!)

-16-

Some practical issues


- The differential masks act as high-pass lters which tend to amplify noise. - To reduce the effects of noise, the image needs to be smoothed rst with a lowpass lter. (1) The noise suppression-localization tradeoff: a lar ger lter reduces noise, but worsens localization (i.e., it adds uncertainty to the location of the edge) and vice versa.

- (2) How should we choose the threshold?

-17- (3) Edge thinning and linking are required to obtain good contours.

Criteria for optimal edge detection


(1) Good detection: the optimal detector must minimize the probability of false positives (detecting spurious edges caused by noise), as well as that of false negatives (missing real edges). (2) Good localization: the edges detected must be as close as possible to the true edges. Single response constraint: the detector must return one point only for each true edge point; that is, minimize the number of local maxima around the true edge (created by noise).

-18-

The Canny edge detector


- This is probably the most widely used edge detector in computer vision. - Canny has shown that the rst derivative of the Gaussian closely approximates the operator that optimizes the product of signal-to-noise ratio and localization. - His analysis is based on "step-edges" corrupted by "additive Gaussian noise".

Algorithm 1. Compute f x and f y fx = fy = ( f * G) = f * G = f * Gx x x ( f * G) = f * G = f * Gy y y

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-

Hysteresis thresholding/Edge Linking


- The output of non-maxima suppression still contains the local maxima created by noise. - Can we get rid of them just by using a single threshold? * if we set a low threshold, some noisy maxima will be accepted too. * if we set a high threshold, true maxima might be missed (the value of true maxima will uctuate above and below the threshold, fragmenting the edge). - A more effective scheme is to use two thresholds: * a low threshold t l * a high threshold t h * usually, t h 2t l Algorithm 1. Produce two thresholded images I 1 (i , j ) and I 2 (i , j ). (note: since I 2 (i , j ) was formed with a high threshold, it will contain fewer false edges but there might be gaps in the contours) 2. Link the edges in I 2 (i , j ) into contours 2.1 Look in I 1 (i , j ) when a gap is found. 2.2 By examining the 8 neighbors in I 1 (i , j ), gather edge points from I 1 (i , j ) until the gap has been bridged to an edge in I 2 (i , j ). - The algorithm performs edge linking as a by-product of double-thresholding !!

-21-

(left:Sobel, middle: thresh=35, right: thersh=50)

(Canny - left: =1, middle: =2, right: =3)


(Canny - 7x7 Gaussian, more details)

-22-

(Canny - 31x31 Gaussian, less details)

-23-

Edge detection using the second derivative


- Edge points can be detected by nding the zero-crossings of the second derivative.

- 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 )

- The Laplacian can be implemented using the mask shown below:

0 1 0

1 -4 1

0 1 0

Example:

-25-

Properties of the Laplacian


- It is an isotropic operator. - It is cheaper to implement (one mask only). - It does not provide information about edge direction. - It is more sensitive to noise (differentiates twice).

The Laplacian-of-Gaussian (LOG)


- To reduce the noise effect, the image is rst smoothed with a low-pass lter. - In the case of the LOG, the low-pass lter is chosen to be a Gaussian. G ( x , y) = e

x 2 + y2 2 2

( determines the degree of smoothing, mask size increases with )

- It can be shown that: 2 [ f ( x , y ) * G ( x , y )] = 2 G ( x , y ) * f ( x , y ) G ( x , y) = (


2

r2

) e r

/2

, (r 2 = x 2 + y 2 )

-26-

-27-

Gradient vs LOG: a comparison


- Gradient works well when the image contains sharp intensity transitions and low noise - Zero-crossings of LOG offer better localization, especially when the edges are not very sharp

-28-

The second directional derivative


- This is the second derivative computed in the direction of the gradient.
2 2 f yy f xx + 2 f x f y f xy + f y fx 2 = 2f2 fx n2 y

Multiscale processing (scale space)


- A serious practical problem with any edge detector is the matter of choosing the scale of smoothing (e.g.,the value of using a Gaussian).

- 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-

(Canny edges at multiple scales of smoothing, =0.5, 1, 2, 4, 8, 16)

You might also like