edge detection - computer sciencelazebnik/spring11/lec06_edge.pdf · 2011-02-08 · edge detection...

25
Edge detection Goal: Identify sudden changes (discontinuities) in changes (discontinuities) in an image Intuitively, most semantic and shape if ti f th i b information from the image can be encoded in the edges More compact than pixels Ideal: artist’s line drawing (but artist is also using (but artist is also using object-level knowledge) Source: D. Lowe

Upload: others

Post on 13-Jul-2020

7 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Edge detection - Computer Sciencelazebnik/spring11/lec06_edge.pdf · 2011-02-08 · Edge detection • Goal: Identify sudden changes (discontinuities) inchanges (discontinuities)

Edge detection

• Goal: Identify sudden changes (discontinuities) inchanges (discontinuities) in an image• Intuitively, most semantic and shape

i f ti f th i binformation from the image can be encoded in the edges

• More compact than pixels

• Ideal: artist’s line drawing (but artist is also using(but artist is also using object-level knowledge)

Source: D. Lowe

Page 2: Edge detection - Computer Sciencelazebnik/spring11/lec06_edge.pdf · 2011-02-08 · Edge detection • Goal: Identify sudden changes (discontinuities) inchanges (discontinuities)

Origin of edges

Edges are caused by a variety of factors:

surface normal discontinuity

depth discontinuity

surface color discontinuity

illumination discontinuity

Source: Steve Seitz

Page 3: Edge detection - Computer Sciencelazebnik/spring11/lec06_edge.pdf · 2011-02-08 · Edge detection • Goal: Identify sudden changes (discontinuities) inchanges (discontinuities)

Characterizing edges• An edge is a place of rapid change in the

image intensity function

imageintensity function

(along horizontal scanline) first derivative

edges correspond toextrema of derivative

Page 4: Edge detection - Computer Sciencelazebnik/spring11/lec06_edge.pdf · 2011-02-08 · Edge detection • Goal: Identify sudden changes (discontinuities) inchanges (discontinuities)

Derivatives with convolutionFor 2D function f(x,y), the partial derivative is:

ε )()()( yxfyxfyxf +∂ε

εε

),(),(lim),(0

yxfyxfx

yxf −+=

∂∂

For discrete data, we can approximate using finite differences:

1),(),1(),( yxfyxf

xyxf −+

≈∂

To implement above as convolution, what would be the associated filter?

1x∂

associated filter?

Source: K. Grauman

Page 5: Edge detection - Computer Sciencelazebnik/spring11/lec06_edge.pdf · 2011-02-08 · Edge detection • Goal: Identify sudden changes (discontinuities) inchanges (discontinuities)

Partial derivatives of an image

f∂ )( f∂ )(x

yxf∂

∂ ),(y

yxf∂

∂ ),(

1 1-1 1

1 -1or-1 1

Which shows changes with respect to x?

Page 6: Edge detection - Computer Sciencelazebnik/spring11/lec06_edge.pdf · 2011-02-08 · Edge detection • Goal: Identify sudden changes (discontinuities) inchanges (discontinuities)

Finite difference filtersOther approximations of derivative filters exist:

Source: K. Grauman

Page 7: Edge detection - Computer Sciencelazebnik/spring11/lec06_edge.pdf · 2011-02-08 · Edge detection • Goal: Identify sudden changes (discontinuities) inchanges (discontinuities)

Image gradient

The gradient of an image:

The gradient points in the direction of most rapid increase in intensity

Th di t di ti i i b

• How does this direction relate to the direction of the edge?

The gradient direction is given by

The edge strength is given by the gradient magnitude

Source: Steve Seitz

Page 8: Edge detection - Computer Sciencelazebnik/spring11/lec06_edge.pdf · 2011-02-08 · Edge detection • Goal: Identify sudden changes (discontinuities) inchanges (discontinuities)

Effects of noiseConsider a single row or column of the image

• Plotting intensity as a function of position gives a signal

Where is the edge?Source: S. Seitz

Page 9: Edge detection - Computer Sciencelazebnik/spring11/lec06_edge.pdf · 2011-02-08 · Edge detection • Goal: Identify sudden changes (discontinuities) inchanges (discontinuities)

Solution: smooth first

f

gg

f *f * g

d )( gfdxd

• To find edges, look for peaks in )( gfdxd

∗Source: S. Seitz

Page 10: Edge detection - Computer Sciencelazebnik/spring11/lec06_edge.pdf · 2011-02-08 · Edge detection • Goal: Identify sudden changes (discontinuities) inchanges (discontinuities)

Derivative theorem of convolution• Differentiation is convolution, and convolution

is associative: gddfgf

dd

∗=∗ )(

• This saves us one operation:dxdx

f

gdd

df

gdx

gdxdf ∗

Source: S. Seitz

Page 11: Edge detection - Computer Sciencelazebnik/spring11/lec06_edge.pdf · 2011-02-08 · Edge detection • Goal: Identify sudden changes (discontinuities) inchanges (discontinuities)

Derivative of Gaussian filter

x-direction y-direction

Are these filters separable?

Page 12: Edge detection - Computer Sciencelazebnik/spring11/lec06_edge.pdf · 2011-02-08 · Edge detection • Goal: Identify sudden changes (discontinuities) inchanges (discontinuities)

Derivative of Gaussian filter

x-direction y-direction

Which one finds horizontal/vertical edges?

Page 13: Edge detection - Computer Sciencelazebnik/spring11/lec06_edge.pdf · 2011-02-08 · Edge detection • Goal: Identify sudden changes (discontinuities) inchanges (discontinuities)

Scale of Gaussian derivative filter

1 pixel 3 pixels 7 pixels

Smoothed derivative removes noise, but blurs edge Also finds edges at different “scales”edge. Also finds edges at different scales

Source: D. Forsyth

Page 14: Edge detection - Computer Sciencelazebnik/spring11/lec06_edge.pdf · 2011-02-08 · Edge detection • Goal: Identify sudden changes (discontinuities) inchanges (discontinuities)

Review: Smoothing vs. derivative filtersSmoothing filters

• Gaussian: remove “high-frequency” components; “l ” filt“low-pass” filter

• Can the values of a smoothing filter be negative?• What should the values sum to?

– One: constant regions are not affected by the filter

Derivative filters• Derivatives of Gaussian

C f f ?• Can the values of a derivative filter be negative?• What should the values sum to?

– Zero: no response in constant regions• High absolute value at points of high contrast

Page 15: Edge detection - Computer Sciencelazebnik/spring11/lec06_edge.pdf · 2011-02-08 · Edge detection • Goal: Identify sudden changes (discontinuities) inchanges (discontinuities)

The Canny edge detector

original imageSlide credit: Steve Seitz

Page 16: Edge detection - Computer Sciencelazebnik/spring11/lec06_edge.pdf · 2011-02-08 · Edge detection • Goal: Identify sudden changes (discontinuities) inchanges (discontinuities)

The Canny edge detector

norm of the gradient

Page 17: Edge detection - Computer Sciencelazebnik/spring11/lec06_edge.pdf · 2011-02-08 · Edge detection • Goal: Identify sudden changes (discontinuities) inchanges (discontinuities)

The Canny edge detector

thresholding

Page 18: Edge detection - Computer Sciencelazebnik/spring11/lec06_edge.pdf · 2011-02-08 · Edge detection • Goal: Identify sudden changes (discontinuities) inchanges (discontinuities)

The Canny edge detector

How to turnHow to turn these thick regions of the gradientthe gradient into curves?

thresholding

Page 19: Edge detection - Computer Sciencelazebnik/spring11/lec06_edge.pdf · 2011-02-08 · Edge detection • Goal: Identify sudden changes (discontinuities) inchanges (discontinuities)

Non-maximum suppression

Check if pixel is local maximum along gradient direction, select single max across width of , gthe edge• requires checking interpolated pixels p and r

Page 20: Edge detection - Computer Sciencelazebnik/spring11/lec06_edge.pdf · 2011-02-08 · Edge detection • Goal: Identify sudden changes (discontinuities) inchanges (discontinuities)

The Canny edge detector

Problem: pixels along this edge didn’t survive thesurvive the thresholding

thinning(non-maximum suppression)

Page 21: Edge detection - Computer Sciencelazebnik/spring11/lec06_edge.pdf · 2011-02-08 · Edge detection • Goal: Identify sudden changes (discontinuities) inchanges (discontinuities)

Hysteresis thresholding

Use a high threshold to start edge curves, and aUse a high threshold to start edge curves, and a low threshold to continue them.

Source: Steve Seitz

Page 22: Edge detection - Computer Sciencelazebnik/spring11/lec06_edge.pdf · 2011-02-08 · Edge detection • Goal: Identify sudden changes (discontinuities) inchanges (discontinuities)

Hysteresis thresholding

original image

high threshold(strong edges)

low threshold(weak edges)

hysteresis threshold

Source: L. Fei-Fei

Page 23: Edge detection - Computer Sciencelazebnik/spring11/lec06_edge.pdf · 2011-02-08 · Edge detection • Goal: Identify sudden changes (discontinuities) inchanges (discontinuities)

Recap: Canny edge detector

1. Filter image with derivative of Gaussian 2. Find magnitude and orientation of gradientg g3. Non-maximum suppression:

• Thin wide “ridges” down to single pixel width4. 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

MATLAB d (i ‘ ’)MATLAB: edge(image, ‘canny’);

J. Canny, A Computational Approach To Edge Detection, IEEE Trans. Pattern Analysis and Machine Intelligence, 8:679-714, 1986.

Page 24: Edge detection - Computer Sciencelazebnik/spring11/lec06_edge.pdf · 2011-02-08 · Edge detection • Goal: Identify sudden changes (discontinuities) inchanges (discontinuities)

Edge detection is just the beginning…

image human segmentation gradient magnitude

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

Page 25: Edge detection - Computer Sciencelazebnik/spring11/lec06_edge.pdf · 2011-02-08 · Edge detection • Goal: Identify sudden changes (discontinuities) inchanges (discontinuities)

Low-level edges vs. perceived contours

Background Texture ShadowsKristen Grauman, UT-Austin