introduction to computer vision - brown universitycs.brown.edu/courses/cs143/2009/lecture9.pdf ·...

36
©Michael J. Black CS143 Intro to Computer Vision Introduction to Computer Vision Michael J. Black Sept 2009 Lecture 9: Image gradients, feature detection, correlation

Upload: others

Post on 06-Oct-2020

4 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Introduction to Computer Vision - Brown Universitycs.brown.edu/courses/cs143/2009/lecture9.pdf · 2009. 10. 5. · Introduction to Computer Vision Michael J. Black Sept 2009 Lecture

©Michael J. Black CS143 Intro to Computer Vision

Introduction to Computer Vision

Michael J. Black

Sept 2009

Lecture 9:

Image gradients, feature detection,

correlation

Page 2: Introduction to Computer Vision - Brown Universitycs.brown.edu/courses/cs143/2009/lecture9.pdf · 2009. 10. 5. · Introduction to Computer Vision Michael J. Black Sept 2009 Lecture

©Michael J. Black CS143 Intro to Computer Vision

Goals

• Image gradient

• Filtering as feature detection

• Convolution vs correlation

• Time permitting: images as vectors

Page 3: Introduction to Computer Vision - Brown Universitycs.brown.edu/courses/cs143/2009/lecture9.pdf · 2009. 10. 5. · Introduction to Computer Vision Michael J. Black Sept 2009 Lecture

©Michael J. Black

Next week

• Wednesday: data for assignment 2.

important that you attend.

• Friday: Silvia Zuffi – color

CS143 Intro to Computer Vision

Page 4: Introduction to Computer Vision - Brown Universitycs.brown.edu/courses/cs143/2009/lecture9.pdf · 2009. 10. 5. · Introduction to Computer Vision Michael J. Black Sept 2009 Lecture

©Michael J. Black CS143 Intro to Computer Vision

Recall derivatives of Gaussian

Page 5: Introduction to Computer Vision - Brown Universitycs.brown.edu/courses/cs143/2009/lecture9.pdf · 2009. 10. 5. · Introduction to Computer Vision Michael J. Black Sept 2009 Lecture

©Michael J. Black CS143 Intro to Computer Vision

What is the gradient?

Change

No Change

Jacobs

Page 6: Introduction to Computer Vision - Brown Universitycs.brown.edu/courses/cs143/2009/lecture9.pdf · 2009. 10. 5. · Introduction to Computer Vision Michael J. Black Sept 2009 Lecture

©Michael J. Black CS143 Intro to Computer Vision

What is the gradient?

No Change

Change

Jacobs

Page 7: Introduction to Computer Vision - Brown Universitycs.brown.edu/courses/cs143/2009/lecture9.pdf · 2009. 10. 5. · Introduction to Computer Vision Michael J. Black Sept 2009 Lecture

©Michael J. Black CS143 Intro to Computer Vision

What is the gradient?

Large Change

Small Change Gradient direction is

perpendicular to edge.

Jacobs

Gradient Magnitude

measures edge strength.

Page 8: Introduction to Computer Vision - Brown Universitycs.brown.edu/courses/cs143/2009/lecture9.pdf · 2009. 10. 5. · Introduction to Computer Vision Michael J. Black Sept 2009 Lecture

©Michael J. Black CS143 Intro to Computer Vision

2D Edge Detection

Take a derivative

– Compute the magnitude of the gradient:

Jacobs

Page 9: Introduction to Computer Vision - Brown Universitycs.brown.edu/courses/cs143/2009/lecture9.pdf · 2009. 10. 5. · Introduction to Computer Vision Michael J. Black Sept 2009 Lecture

©Michael J. Black CS143 Intro to Computer Vision

There are three major issues: 1) The gradient magnitude at different scales is different; which should we choose? 2) The gradient magnitude is large along a thick trail; how do we identify the significant points? 3) How do we link the relevant points up into curves?

Ponce & Forsyth

Page 10: Introduction to Computer Vision - Brown Universitycs.brown.edu/courses/cs143/2009/lecture9.pdf · 2009. 10. 5. · Introduction to Computer Vision Michael J. Black Sept 2009 Lecture

©Michael J. Black CS143 Intro to Computer Vision

Non-Maxima Suppression

Look in a neighborhood along the direction of the gradient.

Choose the largest gradient magnitude in this neighborhood.. Ponce & Forsyth

Page 11: Introduction to Computer Vision - Brown Universitycs.brown.edu/courses/cs143/2009/lecture9.pdf · 2009. 10. 5. · Introduction to Computer Vision Michael J. Black Sept 2009 Lecture

©Michael J. Black CS143 Intro to Computer Vision

Ponce & Forsyth

Page 12: Introduction to Computer Vision - Brown Universitycs.brown.edu/courses/cs143/2009/lecture9.pdf · 2009. 10. 5. · Introduction to Computer Vision Michael J. Black Sept 2009 Lecture

©Michael J. Black CS143 Intro to Computer Vision

fine scalehigh threshold

Ponce & Forsyth

Page 13: Introduction to Computer Vision - Brown Universitycs.brown.edu/courses/cs143/2009/lecture9.pdf · 2009. 10. 5. · Introduction to Computer Vision Michael J. Black Sept 2009 Lecture

©Michael J. Black CS143 Intro to Computer Vision

coarse scale,high threshold

Ponce & Forsyth

Page 14: Introduction to Computer Vision - Brown Universitycs.brown.edu/courses/cs143/2009/lecture9.pdf · 2009. 10. 5. · Introduction to Computer Vision Michael J. Black Sept 2009 Lecture

©Michael J. Black CS143 Intro to Computer Vision

coarsescalelowthreshold

Ponce & Forsyth

Page 15: Introduction to Computer Vision - Brown Universitycs.brown.edu/courses/cs143/2009/lecture9.pdf · 2009. 10. 5. · Introduction to Computer Vision Michael J. Black Sept 2009 Lecture

©Michael J. Black CS143 Intro to Computer Vision

Compare these detected edges to human marked edges:

Humans focus on semantic edges and they don’t always agree.

Berkeley Segmentation Dataset and Benchmark

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

Page 16: Introduction to Computer Vision - Brown Universitycs.brown.edu/courses/cs143/2009/lecture9.pdf · 2009. 10. 5. · Introduction to Computer Vision Michael J. Black Sept 2009 Lecture

©Michael J. Black CS143 Intro to Computer Vision

Berkeley Segmentation Dataset and Benchmark

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

Page 17: Introduction to Computer Vision - Brown Universitycs.brown.edu/courses/cs143/2009/lecture9.pdf · 2009. 10. 5. · Introduction to Computer Vision Michael J. Black Sept 2009 Lecture

©Michael J. Black CS143 Intro to Computer Vision

Direction of the Gradient

Ix

Iy

Page 18: Introduction to Computer Vision - Brown Universitycs.brown.edu/courses/cs143/2009/lecture9.pdf · 2009. 10. 5. · Introduction to Computer Vision Michael J. Black Sept 2009 Lecture

©Michael J. Black CS143 Intro to Computer Vision

Steerable filters

What is the gradient in some direction ?

I (x,y) =I

xcos +

I

ysin = Ix cos +Iy sin

Ix

Iy

|| I ||= IxIx

|| I ||+Iy

Iy|| I ||

=Ix2+ Iy

2

Ix2+ Iy

2= Ix

2+ Iy

2

In the direction of the gradient:

Page 19: Introduction to Computer Vision - Brown Universitycs.brown.edu/courses/cs143/2009/lecture9.pdf · 2009. 10. 5. · Introduction to Computer Vision Michael J. Black Sept 2009 Lecture

©Michael J. Black CS143 Intro to Computer Vision

Features (problem 3) What do the derivatives look like in these neighborhoods?

What can you tell about an image neighborhood from the

local image derivatives?

Page 20: Introduction to Computer Vision - Brown Universitycs.brown.edu/courses/cs143/2009/lecture9.pdf · 2009. 10. 5. · Introduction to Computer Vision Michael J. Black Sept 2009 Lecture

©Michael J. Black CS143 Intro to Computer Vision

Partial derivatives

Page 21: Introduction to Computer Vision - Brown Universitycs.brown.edu/courses/cs143/2009/lecture9.pdf · 2009. 10. 5. · Introduction to Computer Vision Michael J. Black Sept 2009 Lecture

©Michael J. Black CS143 Intro to Computer Vision

Partial derivatives

Page 22: Introduction to Computer Vision - Brown Universitycs.brown.edu/courses/cs143/2009/lecture9.pdf · 2009. 10. 5. · Introduction to Computer Vision Michael J. Black Sept 2009 Lecture

©Michael J. Black CS143 Intro to Computer Vision

Partial derivatives

Page 23: Introduction to Computer Vision - Brown Universitycs.brown.edu/courses/cs143/2009/lecture9.pdf · 2009. 10. 5. · Introduction to Computer Vision Michael J. Black Sept 2009 Lecture

©Michael J. Black CS143 Intro to Computer Vision

Partial derivatives

Page 24: Introduction to Computer Vision - Brown Universitycs.brown.edu/courses/cs143/2009/lecture9.pdf · 2009. 10. 5. · Introduction to Computer Vision Michael J. Black Sept 2009 Lecture

©Michael J. Black CS143 Intro to Computer Vision

Partial derivatives

Page 25: Introduction to Computer Vision - Brown Universitycs.brown.edu/courses/cs143/2009/lecture9.pdf · 2009. 10. 5. · Introduction to Computer Vision Michael J. Black Sept 2009 Lecture

©Michael J. Black CS143 Intro to Computer Vision

Rank of these matrices? (ie maximum number of linearly independent columns)

Page 26: Introduction to Computer Vision - Brown Universitycs.brown.edu/courses/cs143/2009/lecture9.pdf · 2009. 10. 5. · Introduction to Computer Vision Michael J. Black Sept 2009 Lecture

©Michael J. Black CS143 Intro to Computer Vision

Rank?

Page 27: Introduction to Computer Vision - Brown Universitycs.brown.edu/courses/cs143/2009/lecture9.pdf · 2009. 10. 5. · Introduction to Computer Vision Michael J. Black Sept 2009 Lecture

©Michael J. Black CS143 Intro to Computer Vision

Rank?

Page 28: Introduction to Computer Vision - Brown Universitycs.brown.edu/courses/cs143/2009/lecture9.pdf · 2009. 10. 5. · Introduction to Computer Vision Michael J. Black Sept 2009 Lecture

©Michael J. Black CS143 Intro to Computer Vision

Let’s step back a moment…

Convolution Correlation Feature detection

f I H

Notice the “flipping” of the filter.

Page 29: Introduction to Computer Vision - Brown Universitycs.brown.edu/courses/cs143/2009/lecture9.pdf · 2009. 10. 5. · Introduction to Computer Vision Michael J. Black Sept 2009 Lecture

©Michael J. Black CS143 Intro to Computer Vision

Let’s step back a moment…

Convolution Correlation Feature detection

H=imfilter(I, f, 'symmetric', 'conv');

f I H

Page 30: Introduction to Computer Vision - Brown Universitycs.brown.edu/courses/cs143/2009/lecture9.pdf · 2009. 10. 5. · Introduction to Computer Vision Michael J. Black Sept 2009 Lecture

©Michael J. Black CS143 Intro to Computer Vision

Let’s step back a moment…

Convolution Correlation Feature detection

f I H

Page 31: Introduction to Computer Vision - Brown Universitycs.brown.edu/courses/cs143/2009/lecture9.pdf · 2009. 10. 5. · Introduction to Computer Vision Michael J. Black Sept 2009 Lecture

©Michael J. Black CS143 Intro to Computer Vision

Let’s step back a moment…

Convolution Correlation Feature detection

dBarb=imfilter(im, dGx, 'symmetric', 'corr');

f I H

Page 32: Introduction to Computer Vision - Brown Universitycs.brown.edu/courses/cs143/2009/lecture9.pdf · 2009. 10. 5. · Introduction to Computer Vision Michael J. Black Sept 2009 Lecture

©Michael J. Black CS143 Intro to Computer Vision

What’s the difference? Convolution:

Correlation:

Convolution is associative:

Correlation is not.

For symmetric filters, there is no difference.

Page 33: Introduction to Computer Vision - Brown Universitycs.brown.edu/courses/cs143/2009/lecture9.pdf · 2009. 10. 5. · Introduction to Computer Vision Michael J. Black Sept 2009 Lecture

©Michael J. Black

Example: Correlation

[-1 1] [1 -1] [-1 1]

CS143 Intro to Computer Vision

[1 -2 1]

[1 -3 3 -1]

[1 -2 1]

[-1 3 -3 1]

Page 34: Introduction to Computer Vision - Brown Universitycs.brown.edu/courses/cs143/2009/lecture9.pdf · 2009. 10. 5. · Introduction to Computer Vision Michael J. Black Sept 2009 Lecture

©Michael J. Black

Example: Convolution

[-1 1] [1 -1] [-1 1]

CS143 Intro to Computer Vision

[-1 2 -1]

[1 -3 3 -1]

[-1 2 -1]

[1 -3 3 -1]

Page 35: Introduction to Computer Vision - Brown Universitycs.brown.edu/courses/cs143/2009/lecture9.pdf · 2009. 10. 5. · Introduction to Computer Vision Michael J. Black Sept 2009 Lecture

©Michael J. Black CS143 Intro to Computer Vision

Strange, eh?

• In the Fourier domain this is easy to explain (convolution is multiplication in the Fourier domain and is hence associative but correlation involves taking the complex conjugate of the filter – if the order is reversed, you take the complex conjugate of the image which changes the result).

• For this class this can essentially be ignored. From now on we’ll mostly use correlation.

• If you don’t believe it, try out the Matlab script on the web for this lecture.

Page 36: Introduction to Computer Vision - Brown Universitycs.brown.edu/courses/cs143/2009/lecture9.pdf · 2009. 10. 5. · Introduction to Computer Vision Michael J. Black Sept 2009 Lecture

©Michael J. Black

Convolution vs Correlation

CS143 Intro to Computer Vision

http://www-structmed.cimr.cam.ac.uk/Course/Convolution/convolution.html