lecture 2: convolution and edge detection cs4670: computer vision noah snavely from sandlot...

29
Lecture 2: Convolution and edge detection CS4670: Computer Vision Noah Snavely From Sandlot Science

Upload: lisa-arledge

Post on 14-Dec-2015

227 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Lecture 2: Convolution and edge detection CS4670: Computer Vision Noah Snavely From Sandlot ScienceSandlot Science

Lecture 2: Convolution and edge detection

CS4670: Computer VisionNoah Snavely

From Sandlot Science

Page 2: Lecture 2: Convolution and edge detection CS4670: Computer Vision Noah Snavely From Sandlot ScienceSandlot Science

Gaussian Kernel

Source: C. Rasmussen

Page 3: Lecture 2: Convolution and edge detection CS4670: Computer Vision Noah Snavely From Sandlot ScienceSandlot Science

Mean vs. Gaussian filtering

Page 4: Lecture 2: Convolution and edge detection CS4670: Computer Vision Noah Snavely From Sandlot ScienceSandlot Science

Gaussian filters

= 30 pixels= 1 pixel = 5 pixels = 10 pixels

Page 5: Lecture 2: Convolution and edge detection CS4670: Computer Vision Noah Snavely From Sandlot ScienceSandlot Science

Gaussian filter• Removes “high-frequency” components from

the image (low-pass filter)• Convolution with self is another Gaussian

– Convolving two times with Gaussian kernel of width = convolving once with kernel of width

Source: K. Grauman

* =

Page 6: Lecture 2: Convolution and edge detection CS4670: Computer Vision Noah Snavely From Sandlot ScienceSandlot Science

Sharpening

Source: D. Lowe

Page 7: Lecture 2: Convolution and edge detection CS4670: Computer Vision Noah Snavely From Sandlot ScienceSandlot Science

Sharpening revisited• What does blurring take away?

original smoothed (5x5)

detail

=

sharpened

=

Let’s add it back:

original detail

+ α

Source: S. Lazebnik

Page 8: Lecture 2: Convolution and edge detection CS4670: Computer Vision Noah Snavely From Sandlot ScienceSandlot Science

Sharpen filter

Gaussianscaled impulseLaplacian of Gaussian

imageblurredimage unit impulse

(identity)

Page 9: Lecture 2: Convolution and edge detection CS4670: Computer Vision Noah Snavely From Sandlot ScienceSandlot Science

Sharpen filter

unfiltered

filtered

Page 10: Lecture 2: Convolution and edge detection CS4670: Computer Vision Noah Snavely From Sandlot ScienceSandlot Science

Convolution in the real world

Source: http://lullaby.homepage.dk/diy-camera/bokeh.html

Bokeh: Blur in out-of-focus regions of an image.

Camera shake

*=Source: Fergus, et al. “Removing Camera Shake from a Single Photograph”, SIGGRAPH 2006

Page 11: Lecture 2: Convolution and edge detection CS4670: Computer Vision Noah Snavely From Sandlot ScienceSandlot Science

Questions?

Page 12: Lecture 2: Convolution and edge detection CS4670: Computer Vision Noah Snavely From Sandlot ScienceSandlot Science

Image noise

http://theory.uchicago.edu/~ejm/pix/20d/tests/noise/index.html

Original image White Gaussian noise Salt and pepper noise(each pixel has some chance of being switched to zero or one)

Page 13: Lecture 2: Convolution and edge detection CS4670: Computer Vision Noah Snavely From Sandlot ScienceSandlot Science

Gaussian noise

= 1 pixel = 2 pixels = 5 pixels

Smoothing with larger standard deviations suppresses noise, but also blurs the image

Page 14: Lecture 2: Convolution and edge detection CS4670: Computer Vision Noah Snavely From Sandlot ScienceSandlot Science

Salt & pepper noise – Gaussian blur

= 1 pixel = 2 pixels = 5 pixels

• What’s wrong with the results?

p = 10%

Page 15: Lecture 2: Convolution and edge detection CS4670: Computer Vision Noah Snavely From Sandlot ScienceSandlot Science

Alternative idea: Median filtering• A median filter operates over a window by

selecting the median intensity in the window

• Is median filtering linear?Source: K. Grauman

Page 16: Lecture 2: Convolution and edge detection CS4670: Computer Vision Noah Snavely From Sandlot ScienceSandlot Science

Median filter• What advantage does median filtering have

over Gaussian filtering?

Source: K. Grauman

Page 17: Lecture 2: Convolution and edge detection CS4670: Computer Vision Noah Snavely From Sandlot ScienceSandlot Science

Salt & pepper noise – median filtering

= 1 pixel = 2 pixels = 5 pixels

3x3 window 5x5 window 7x7 window

p = 10%

Page 18: Lecture 2: Convolution and edge detection CS4670: Computer Vision Noah Snavely From Sandlot ScienceSandlot Science

Edge detection

• Convert a 2D image into a set of curves– Extracts salient features of the scene– More compact than pixels

Page 19: Lecture 2: Convolution and edge detection CS4670: Computer Vision Noah Snavely From Sandlot ScienceSandlot Science

Origin of Edges

• Edges are caused by a variety of factors

depth discontinuity

surface color discontinuity

illumination discontinuity

surface normal discontinuity

Page 20: Lecture 2: Convolution and edge detection CS4670: Computer Vision Noah Snavely From Sandlot ScienceSandlot Science

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 derivativeSource: L. Lazebnik

Page 21: Lecture 2: Convolution and edge detection CS4670: Computer Vision Noah Snavely From Sandlot ScienceSandlot Science

• How can we differentiate a digital image F[x,y]?– Option 1: reconstruct a continuous image, f, then

compute the derivative– Option 2: take discrete derivative (finite

difference)

1 -1

How would you implement this as a linear filter?

Image derivatives

-1

1: :

Source: S. Seitz

Page 22: Lecture 2: Convolution and edge detection CS4670: Computer Vision Noah Snavely From Sandlot ScienceSandlot Science

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

Image gradient• The gradient of an image:

The edge strength is given by the gradient magnitude:

The gradient direction is given by:

• how does this relate to the direction of the edge?Source: Steve Seitz

Page 23: Lecture 2: Convolution and edge detection CS4670: Computer Vision Noah Snavely From Sandlot ScienceSandlot Science

Image gradient

Source: L. Lazebnik

Page 24: Lecture 2: Convolution and edge detection CS4670: Computer Vision Noah Snavely From Sandlot ScienceSandlot Science

Effects of noise

Where is the edge?Source: S. Seitz

Noisy input image

Page 25: Lecture 2: Convolution and edge detection CS4670: Computer Vision Noah Snavely From Sandlot ScienceSandlot Science

Solution: smooth first

f

h

f * h

Source: S. SeitzTo find edges, look for peaks in

Page 26: Lecture 2: Convolution and edge detection CS4670: Computer Vision Noah Snavely From Sandlot ScienceSandlot Science

• Differentiation is convolution, and convolution is associative:

• This saves us one operation:

Associative property of convolution

f

Source: S. Seitz

Page 27: Lecture 2: Convolution and edge detection CS4670: Computer Vision Noah Snavely From Sandlot ScienceSandlot Science

2D edge detection filters

Gaussianderivative of Gaussian (x)

Page 28: Lecture 2: Convolution and edge detection CS4670: Computer Vision Noah Snavely From Sandlot ScienceSandlot Science

Derivative of Gaussian filter

x-direction y-direction

Page 29: Lecture 2: Convolution and edge detection CS4670: Computer Vision Noah Snavely From Sandlot ScienceSandlot Science

The Sobel operator• Common approximation of derivative of Gaussian

-1 0 1

-2 0 2

-1 0 1

1 2 1

0 0 0

-1 -2 -1

• The standard defn. of the Sobel operator omits the 1/8 term– doesn’t make a difference for edge detection– the 1/8 term is needed to get the right gradient value