40
Edge Detection INEL 6088 - Fall 2011 - M. Toledo Tuesday, September 13, 11

Chapter 5: Edge Detection

  • Upload
    others

  • View
    6

  • Download
    0

Embed Size (px)

Citation preview

Page 1: Chapter 5: Edge Detection

Edge DetectionINEL 6088 - Fall 2011 - M. Toledo

Tuesday, September 13, 11

Page 2: Chapter 5: Edge Detection

2

ideal

~real

Tuesday, September 13, 11

Page 3: Chapter 5: Edge Detection

Edge point – point at which the local intensity changes significantly

Edge fragment – edge (point) and orientation

Edge detector – produces a set of edges (points or fragments)

Edge linking – orders a list of edges

Contour – list of edges

Edge following – searching the (input) image to determine contours

Tuesday, September 13, 11

Page 4: Chapter 5: Edge Detection

4

Real image

Edge detector produces:• correct edges• false edges (false positives)• can miss edges (false negatives)

Tuesday, September 13, 11

Page 5: Chapter 5: Edge Detection

5

Edge Detection using Gradient

G[f(x,y)]=[Gx Gy]T

Gx = δf/δx ≈ f[i,j+1]-f[i,j] « gradient at [i, j+½] Gy = δf/δy ≈ f[i+1,j]-f[i,j] « gradient at [i+½, j]

To get the gradient at the same point [i+½, j+½], use:

Simple way

Tuesday, September 13, 11

Page 6: Chapter 5: Edge Detection

6

Steps:• filtering• enhancement• detection• sometimes, localization

Roberts: P5 = |P5 - P9| + |P8 – P6|

i

j

Sobel: C= mult. by 2

Prewitt: Sobel with c=1

Tuesday, September 13, 11

Page 7: Chapter 5: Edge Detection

7

Filtered with 7x7 gaussian filter

Tuesday, September 13, 11

Page 8: Chapter 5: Edge Detection

8

unfiltered

Tuesday, September 13, 11

Page 9: Chapter 5: Edge Detection

9

Filtered, noisy

Tuesday, September 13, 11

Page 10: Chapter 5: Edge Detection

10

Unfiltered, noisy

Tuesday, September 13, 11

Page 11: Chapter 5: Edge Detection

11

Edge Detectors that use the Second Derivative

Change in sign

indicates edgeTwo ways:

• Laplacian• Second directional derivative

Tuesday, September 13, 11

Page 12: Chapter 5: Edge Detection

12

Laplacian

Combined to get

Also used:

Tuesday, September 13, 11

Page 13: Chapter 5: Edge Detection

13

Tuesday, September 13, 11

Page 14: Chapter 5: Edge Detection

14

Tuesday, September 13, 11

Page 15: Chapter 5: Edge Detection

15

Second directional derivative

n Second derivative computed in the direction of the gradient

n Implement using the formula:

Tuesday, September 13, 11

Page 16: Chapter 5: Edge Detection

16

Laplacian of Gaussian (LoG)

Problem with Laplacian and second-derivative-operator: • very sensitive to noise• Small peaks in first derivative produce zero-crossing in the second derivative.

Solution: Filter out noise before edge enhancement

n Smoothing: Gaussian smoothingn Enhancement: Second-derivative edge enhancementn Detection: zero-crossing in the second derivative with a corresponding

large peak (i.e. above some threshold) in the first derivativen If desired, use linear interpolation to locate the edge with sub-pixel

resolution

Tuesday, September 13, 11

Page 17: Chapter 5: Edge Detection

17

Mexican-hatOperator

The output of the LoG operator, h(x,y) is given by:

h(x, y) = r2[g(x, y) ? f(x, y)]

h(x, y) = [r2g(x, y)] ? f(x, y)

r2g(x, y) =

x

2+ y

2 � 2�

2

4exp

✓�x

2+ y

2

2�

2

Tuesday, September 13, 11

Page 18: Chapter 5: Edge Detection

18

Two ways of doing LoG:• Gaussian smoothing followed by laplacian• Convolution of image with a linear filter that is the laplacian of a gaussian filter

To obtain real edges, it might be necessary to combine information from filters of different sizes. The problem of combining edges obtained from different size operators still remains.

Tuesday, September 13, 11

Page 19: Chapter 5: Edge Detection

19

Tuesday, September 13, 11

Page 20: Chapter 5: Edge Detection

20

LoG ResultsSmoothing causes blurring large σ: better noise filtering but more blurring – can cause edge merging

By applying filters of different sizes and analyzing the results, better edge detection can be accomplished.

Tuesday, September 13, 11

Page 21: Chapter 5: Edge Detection

21

An alternative approach is to fit a function to the image and then detect

the edges in the function…

Tuesday, September 13, 11

Page 22: Chapter 5: Edge Detection

22

Facet model: fit a function only in the local neighborhood of each pixel.

Tuesday, September 13, 11

Page 23: Chapter 5: Edge Detection

23

Example: bicubic polynomial

Tuesday, September 13, 11

Page 24: Chapter 5: Edge Detection

24

Masks for computing the coefficients of the bicubic approximation.

Tuesday, September 13, 11

Page 25: Chapter 5: Edge Detection

25

Tuesday, September 13, 11

Page 26: Chapter 5: Edge Detection

26

The angle may be chosen to be the angle of the approximating

plane:

sin ✓ =

k3pk22 + k23

cos ✓ =

k2pk22 + k23

f

00✓ (x0, y0) = 2(3k7 cos

2✓ + 2k8 sin ✓ cos ✓ + k9 sin

2✓)x0

+2(k8 cos2✓ + 2k9 sin ✓ cos ✓ + 3k10 sin

2✓)y0

+2(k4 cos2✓ + k5 sin ✓ cos ✓ + k6 sin

2✓)

f

0✓(x, y) =

@f

@x

cos ✓ +

@f

@y

sin ✓

f

00✓ (x, y) =

@

2f

@x

2cos

2✓ + 2

@

2f

@x@y

cos ✓ sin ✓ +

@

2f

@y

2sin

2✓

Tuesday, September 13, 11

Page 27: Chapter 5: Edge Detection

27

There is an edge at (x0,y0) if for some ρ, | ρ |< ρ0 where ρ0 is the length of the side of a pixel,

fθ”(x0,y0; ρ) = 0 and

fθ’(x0,y0; ρ) ≠ 0

x0 = ⇢ cos ✓

y0 = ⇢ sin ✓

f

00✓ (x0, y0) = 6(k10 sin

3✓ + k9 sin

2✓ cos ✓ + k8 sin ✓ cos

2✓ + k7 cos

3✓)⇢

+2(k6 sin2✓ + k5 sin ✓ cos ✓ + k4 cos

2✓)

= A⇢+B

Tuesday, September 13, 11

Page 28: Chapter 5: Edge Detection

28

Tuesday, September 13, 11

Page 29: Chapter 5: Edge Detection

29

Tuesday, September 13, 11

Page 30: Chapter 5: Edge Detection

30

Canny Edge detectionn Let I[i,j] be the image. First use Gaussian smoothing:

S[i,j]=G[i,j;σ]*I[i,j]n Find approx. gradient usin 2×2 first-diff. approx.

q x direction:

P[i,j]=(S[i,j+1]-S[i,j]+S[i+1,j+1]-S[i+1,j])/2q y direction:

Q[i,j]=(S[i,j]-S[i+1,j]+S[i,j+1]-S[i+1,j+1])/2

Tuesday, September 13, 11

Page 31: Chapter 5: Edge Detection

31

Canny edge detection (cont)

n Magnitude and orientation: rectangular to polar conversion:q M[I,j]=√(P[i,j]2+Q[i,j]2) q θ[i,j] = arctan(Q[i,j]/P[i,j])

n Non-maxima Suppressionq Thins the ridges of gradient magnitude to one pixelq Passes a 3x3 neighborhood across the magnitude

array M[I,j] and replace pixels with 0 if not greater than neighbors

Tuesday, September 13, 11

Page 32: Chapter 5: Edge Detection

32

Possible gradient orientations are partitioned into the following sectors for

non-maxima suppression

876

504

321

Replace pixel 0 with value 0 if it is not bigger than neighboring pixels in the (quantized) direction of the

gradient

Tuesday, September 13, 11

Page 33: Chapter 5: Edge Detection

33

Canny Edge detection (cont)

n Thresholdingq Apply two threshold t1 and t2, with t2 = 2*t1q This produces two threshold images T1 & T2q T2 will have fewer edges, but might have gapsq When the end of a contour in T2 is reached, look into

T1 at the 8-neighboring locations to see if there are further edge points that can be linked to the contour.

Tuesday, September 13, 11

Page 34: Chapter 5: Edge Detection

34

Test Image (256x256)

Tuesday, September 13, 11

Page 35: Chapter 5: Edge Detection

35

Canny with 7x7 Gaussian smoothing + gradient approx + NMS

Tuesday, September 13, 11

Page 36: Chapter 5: Edge Detection

36

Canny with 31x31 Gaussian smoothing

Tuesday, September 13, 11

Page 37: Chapter 5: Edge Detection

37

Edge Detector Performance Evaluationn Probability of false edgesn Probability of missing edgesn Edge angle estimation errorn Mean square distance between estimated and real edgesn Tolerance to distorted edges

Tuesday, September 13, 11

Page 38: Chapter 5: Edge Detection

38

Pratt´s Figure of Merit

detected edges

ideal edges

distance betweenactual and ideal

edges

constant used to penalize displaced edges

FM =

1

max(IA, II)

IAX

i=1

1

1 + ↵d2i

Tuesday, September 13, 11

Page 39: Chapter 5: Edge Detection

39

Sequential Methods

Edge following: scan image looking for strong edge extend the edge in the proper direction by looking at neighboring edges link if directions are compatible look at large neighborhood to fill in missing edges

Tuesday, September 13, 11

Page 40: Chapter 5: Edge Detection

40

Tuesday, September 13, 11