Canny Edge DetectionDetection/Localization trade-off • More smoothing improves detection ... Leung...

32
Canny Edge Detection Mohammad Nayeem Teli

Transcript of Canny Edge DetectionDetection/Localization trade-off • More smoothing improves detection ... Leung...

Page 1: Canny Edge DetectionDetection/Localization trade-off • More smoothing improves detection ... Leung & Malik, Representing and Recognizing the Visual ... pB Boundary Detector - Estimate

Canny Edge Detection

Mohammad Nayeem Teli

Page 2: Canny Edge DetectionDetection/Localization trade-off • More smoothing improves detection ... Leung & Malik, Representing and Recognizing the Visual ... pB Boundary Detector - Estimate

Optimal Edge Detection: Canny

Assume: • Linear filtering • Additive iid Gaussian noise

Edge detector should have: • Good Detection. Filter responds to edge, not noise. • Good Localization: detected edge near true edge. • Single Response: one per edge.

Page 3: Canny Edge DetectionDetection/Localization trade-off • More smoothing improves detection ... Leung & Malik, Representing and Recognizing the Visual ... pB Boundary Detector - Estimate

Optimal Edge Detection: Canny (continued)Optimal Detector is approximately Derivative of

Gaussian. Detection/Localization trade-off

• More smoothing improves detection • And hurts localization.

This is what you might guess from (detect change) + (remove noise)

Page 4: Canny Edge DetectionDetection/Localization trade-off • More smoothing improves detection ... Leung & Malik, Representing and Recognizing the Visual ... pB Boundary Detector - Estimate

Canny edge detector1. Smoothing (noise reduction) 2. Find derivatives (gradients) 3. Find magnitude and orientation of gradient 4. Non-maximum suppression:

• Thin multi-pixel wide “ridges” down to single pixel width

5. Linking and thresholding (hysteresis): • Define two thresholds: low and high • Use the high threshold to start edge curves and the low

threshold to continue them

Page 5: Canny Edge DetectionDetection/Localization trade-off • More smoothing improves detection ... Leung & Malik, Representing and Recognizing the Visual ... pB Boundary Detector - Estimate

The Canny edge detector

original image

Page 6: Canny Edge DetectionDetection/Localization trade-off • More smoothing improves detection ... Leung & Malik, Representing and Recognizing the Visual ... pB Boundary Detector - Estimate

Canny edge detector1. Smoothing (noise reduction)

5 x 5 Gaussian kernel

12πσ2

e− (x2 + y2)2σ2

x = i − (k + 1); y = j − (k + 1)

Filter : (2k + 1) × (2k + 1) −2 ≤ k ≤ 2

1 ≤ i, j ≤ 2k + 1

Page 7: Canny Edge DetectionDetection/Localization trade-off • More smoothing improves detection ... Leung & Malik, Representing and Recognizing the Visual ... pB Boundary Detector - Estimate

The Canny edge detector

smoothed image

Page 8: Canny Edge DetectionDetection/Localization trade-off • More smoothing improves detection ... Leung & Malik, Representing and Recognizing the Visual ... pB Boundary Detector - Estimate

Canny edge detector1. Smoothing (noise reduction) 2. Find derivatives (gradients)

hx

hy

Fx

Fy

Page 9: Canny Edge DetectionDetection/Localization trade-off • More smoothing improves detection ... Leung & Malik, Representing and Recognizing the Visual ... pB Boundary Detector - Estimate

Canny edge detector1. Smoothing (noise reduction) 2. Find derivatives (gradients) 3. Find magnitude and orientation of gradient

Fx

Fy G = (F2x + F2

y )

Page 10: Canny Edge DetectionDetection/Localization trade-off • More smoothing improves detection ... Leung & Malik, Representing and Recognizing the Visual ... pB Boundary Detector - Estimate

Canny edge detector1. Smoothing (noise reduction) 2. Find derivatives (gradients) 3. Find magnitude and orientation of gradient

Fx

Fyθ = tan−1( Fy

Fx )

Page 11: Canny Edge DetectionDetection/Localization trade-off • More smoothing improves detection ... Leung & Malik, Representing and Recognizing the Visual ... pB Boundary Detector - Estimate

Non-maximum suppression

Check if pixel is local maximum along gradient direction • requires checking interpolated pixels p and r

Page 12: Canny Edge DetectionDetection/Localization trade-off • More smoothing improves detection ... Leung & Malik, Representing and Recognizing the Visual ... pB Boundary Detector - Estimate

Canny edge detector1. Smoothing (noise reduction) 2. Find derivatives (gradients) 3. Find magnitude and orientation of gradient 4. Non-maximum suppression:

• Thin multi-pixel wide “ridges” down to single pixel width

0

π4π

2

3π4

π

Page 13: Canny Edge DetectionDetection/Localization trade-off • More smoothing improves detection ... Leung & Malik, Representing and Recognizing the Visual ... pB Boundary Detector - Estimate

Canny edge detector1. Smoothing (noise reduction) 2. Find derivatives (gradients) 3. Find magnitude and orientation of gradient 4. Non-maximum suppression:

• Thin multi-pixel wide “ridges” down to single pixel width

0

π4π

2

3π4

π

Page 14: Canny Edge DetectionDetection/Localization trade-off • More smoothing improves detection ... Leung & Malik, Representing and Recognizing the Visual ... pB Boundary Detector - Estimate

Canny edge detector1. Smoothing (noise reduction) 2. Find derivatives (gradients) 3. Find magnitude and orientation of gradient 4. Non-maximum suppression:

• Thin multi-pixel wide “ridges” down to single pixel width

5. Linking and thresholding (hysteresis): • Define two thresholds: low and high

Upper threshold based on the max intensity

lower threshold based on some percentage of the upper threshold

Page 15: Canny Edge DetectionDetection/Localization trade-off • More smoothing improves detection ... Leung & Malik, Representing and Recognizing the Visual ... pB Boundary Detector - Estimate

Canny edge detector - double threshold

1. Linking and thresholding (hysteresis): • Define two thresholds: low and high

Upper threshold based on the max intensity

lower threshold based on some percentage of the upper threshold

Example:

Upper threshold - 90% of max lower threshold - 35%

lower threshold < intensity < upper threshold

<= lower threshold >=

upper threshold

irrelevant weak strong

Page 16: Canny Edge DetectionDetection/Localization trade-off • More smoothing improves detection ... Leung & Malik, Representing and Recognizing the Visual ... pB Boundary Detector - Estimate

Canny edge detector - double threshold

1. Linking and thresholding (hysteresis): • Define two thresholds: low and high

Upper threshold based on the max intensity

lower threshold based on some percentage of the upper threshold

Example:

Upper threshold - 90% of max lower threshold - 35%

lower threshold < intensity < upper threshold

<= lower threshold >=

upper threshold

irrelevant = 0 weak = low threshold

strong= 255

Page 17: Canny Edge DetectionDetection/Localization trade-off • More smoothing improves detection ... Leung & Malik, Representing and Recognizing the Visual ... pB Boundary Detector - Estimate

Canny edge detector - Hysteresis1. Smoothing (noise reduction) 2. Find derivatives (gradients) 3. Find magnitude and orientation of gradient 4. Non-maximum suppression:

• Thin multi-pixel wide “ridges” down to single pixel width

5. Linking and thresholding (hysteresis): • Define two thresholds: low and high • replace with the strong edge if any of the neighboring pixels

is strong, else make it irrelevant.

0

π4π

2

3π4

π

Page 18: Canny Edge DetectionDetection/Localization trade-off • More smoothing improves detection ... Leung & Malik, Representing and Recognizing the Visual ... pB Boundary Detector - Estimate

Canny edge detector - Hysteresis1. Smoothing (noise reduction) 2. Find derivatives (gradients) 3. Find magnitude and orientation of gradient 4. Non-maximum suppression:

• Thin multi-pixel wide “ridges” down to single pixel width

5. Linking and thresholding (hysteresis): • Define two thresholds: low and high • replace with the strong edge if any of the neighboring pixels

is strong, else make it irrelevant.

0

π4π

2

3π4

π

Page 19: Canny Edge DetectionDetection/Localization trade-off • More smoothing improves detection ... Leung & Malik, Representing and Recognizing the Visual ... pB Boundary Detector - Estimate

Canny Edge Detection (Example)

courtesy of G. Loy

gap is gone

Original image

Strong edges

only

Strong + connected weak edges

Weak edges

Page 20: Canny Edge DetectionDetection/Localization trade-off • More smoothing improves detection ... Leung & Malik, Representing and Recognizing the Visual ... pB Boundary Detector - Estimate

Effect of σ (Gaussian kernel size)

Canny with Canny with original

The choice of depends on desired behavior • large detects large scale edges • small detects fine features

Page 21: Canny Edge DetectionDetection/Localization trade-off • More smoothing improves detection ... Leung & Malik, Representing and Recognizing the Visual ... pB Boundary Detector - Estimate

(Forsyth & Ponce)

Scale

Smoothing Eliminates noise edges. Makes edges smoother. Removes fine detail.

Page 22: Canny Edge DetectionDetection/Localization trade-off • More smoothing improves detection ... Leung & Malik, Representing and Recognizing the Visual ... pB Boundary Detector - Estimate
Page 23: Canny Edge DetectionDetection/Localization trade-off • More smoothing improves detection ... Leung & Malik, Representing and Recognizing the Visual ... pB Boundary Detector - Estimate

fine scale high threshold

Page 24: Canny Edge DetectionDetection/Localization trade-off • More smoothing improves detection ... Leung & Malik, Representing and Recognizing the Visual ... pB Boundary Detector - Estimate

coarse scale, high threshold

Page 25: Canny Edge DetectionDetection/Localization trade-off • More smoothing improves detection ... Leung & Malik, Representing and Recognizing the Visual ... pB Boundary Detector - Estimate

coarse scale low threshold

Page 26: Canny Edge DetectionDetection/Localization trade-off • More smoothing improves detection ... Leung & Malik, Representing and Recognizing the Visual ... pB Boundary Detector - Estimate

Computer Vision - A Modern

Approach Set: Linear Filters

Slides by D.A. Forsyth

Filters are templates

■ Applying a filter at some point can be seen as taking a dot-product between the image and some vector

■ Filtering the image is a set of dot products

■ Insight■ filters look like the effects

they are intended to find ■ filters find effects they look

like

Page 27: Canny Edge DetectionDetection/Localization trade-off • More smoothing improves detection ... Leung & Malik, Representing and Recognizing the Visual ... pB Boundary Detector - Estimate

Filter Bank

Leung & Malik, Representing and Recognizing the Visual Apperance using 3D Textons, IJCV 2001

Page 28: Canny Edge DetectionDetection/Localization trade-off • More smoothing improves detection ... Leung & Malik, Representing and Recognizing the Visual ... pB Boundary Detector - Estimate

Learning to detect boundaries

Berkeley segmentation database:http://www.eecs.berkeley.edu/Research/Projects/CS/vision/grouping/segbench/

image human segmentation gradient magnitude

Page 29: Canny Edge DetectionDetection/Localization trade-off • More smoothing improves detection ... Leung & Malik, Representing and Recognizing the Visual ... pB Boundary Detector - Estimate

pB boundary detector

Figure from Fowlkes

Martin, Fowlkes, Malik 2004: Learning to Detection Natural Boundaries… http://www.eecs.berkeley.edu/Research/Projects/CS/vision/grouping/papers/mfm-pami-boundary.pdf

Page 30: Canny Edge DetectionDetection/Localization trade-off • More smoothing improves detection ... Leung & Malik, Representing and Recognizing the Visual ... pB Boundary Detector - Estimate

pB Boundary Detector

- Estimate Posterior probability of boundary passing through centre point based on local patch based features - Using a Supervised Learning based framework

Page 31: Canny Edge DetectionDetection/Localization trade-off • More smoothing improves detection ... Leung & Malik, Representing and Recognizing the Visual ... pB Boundary Detector - Estimate

Results

Human (0.95)

Pb (0.88)

Page 32: Canny Edge DetectionDetection/Localization trade-off • More smoothing improves detection ... Leung & Malik, Representing and Recognizing the Visual ... pB Boundary Detector - Estimate

Results

Human

Pb

Human (0.96)

Global PbPb (0.88)