81
Fitting a transformation: feature-based alignment Thursday, September 24 th 2015 Devi Parikh Virginia Tech 1 Slide credit: Kristen Grauman Disclaimer: Many slides have been borrowed from Kristen Grauman, who may have borrowed some of them from others. Any time a slide did not already have a credit on it, I have credited it to Kristen. So there is a chance some of these credits are inaccurate.

Fitting a transformation: feature-based alignment Thursday, September 24 th 2015 Devi Parikh Virginia Tech 1 Slide credit: Kristen Grauman Disclaimer:

Embed Size (px)

Citation preview

Page 1: Fitting a transformation: feature-based alignment Thursday, September 24 th 2015 Devi Parikh Virginia Tech 1 Slide credit: Kristen Grauman Disclaimer:

Fitting a transformation:feature-based alignment

Thursday, September 24th 2015Devi Parikh

Virginia Tech

1Slide credit: Kristen Grauman

Disclaimer: Many slides have been borrowed from Kristen Grauman, who may have borrowed some of them from others. Any time a slide did not already have a credit on it, I have credited it to Kristen. So there is a chance some of these credits are inaccurate.

Page 2: Fitting a transformation: feature-based alignment Thursday, September 24 th 2015 Devi Parikh Virginia Tech 1 Slide credit: Kristen Grauman Disclaimer:

Announcements

• Project proposals– Due Tuesday– Teams of > 2– Look at class webpage for guidelines

• PS2 out– Due October 5th

• PS1 graded– Grades will be released soon

2Slide credit: Adapted by Devi Parikh from Kristen Grauman

Page 3: Fitting a transformation: feature-based alignment Thursday, September 24 th 2015 Devi Parikh Virginia Tech 1 Slide credit: Kristen Grauman Disclaimer:

Given: initial contour (model) near desired object

a.k.a. active contours, snakes

Figure credit: Yuri Boykov

Goal: evolve the contour to fit exact object boundary

[Snakes: Active contour models, Kass, Witkin, & Terzopoulos, ICCV1987]

Main idea: elastic band is iteratively adjusted so as to• be near image positions with

high gradients, and• satisfy shape “preferences” or

contour priors

Last time: Deformable contours

3

Slide credit: Kristen Grauman

Page 4: Fitting a transformation: feature-based alignment Thursday, September 24 th 2015 Devi Parikh Virginia Tech 1 Slide credit: Kristen Grauman Disclaimer:

Last time: Deformable contours

Image from http://www.healthline.com/blogs/exercise_fitness/uploaded_images/HandBand2-795868.JPG Kristen Grauman

4

Page 5: Fitting a transformation: feature-based alignment Thursday, September 24 th 2015 Devi Parikh Virginia Tech 1 Slide credit: Kristen Grauman Disclaimer:

Recap: deformable contour

• A simple elastic snake is defined by:– A set of n points,– An internal energy term (tension,

bending, plus optional shape prior)– An external energy term (gradient-based)

• To use to segment an object:– Initialize in the vicinity of the object– Modify the points to minimize the total

energy

Kristen Grauman

5

Page 6: Fitting a transformation: feature-based alignment Thursday, September 24 th 2015 Devi Parikh Virginia Tech 1 Slide credit: Kristen Grauman Disclaimer:

),( 44 nvvE),( 433 vvE

)3(3E

)(3 mE )(4 mE

)3(4E

)2(4E

)1(4E

)(mEn

)3(nE

)2(nE

)1(nE

)2(3E

)1(3E

)(2 mE

)3(2E

),(...),(),( 11322211 nnntotal vvEvvEvvEE

),( 322 vvE

)1(2E

)2(2E

),( 211 vvE

0)1(1 E

0)2(1 E

0)3(1 E

0)(1 mE

Main idea: determine optimal position (state) of predecessor, for each possible position of self. Then backtrack from best state for last vertex.

states

1

2

m

vert

ices

1v 2v 3v 4v nv

)( 2nmOComplexity: vs. brute force search ____?

Viterbi algorithm

Example adapted from Y. Boykov

6

Slide credit: Kristen Grauman

Page 7: Fitting a transformation: feature-based alignment Thursday, September 24 th 2015 Devi Parikh Virginia Tech 1 Slide credit: Kristen Grauman Disclaimer:

),(...),(),( 11322211 nnn vvEvvEvvE DP can be applied to optimize an open ended snake

For a closed snake, a “loop” is introduced into the total energy.

1n

),(),(...),(),( 111322211 vvEvvEvvEvvE nnnnn

1n

2

1n

3 4

Work around:

1) Fix v1 and solve for rest .

2) Fix an intermediate node at its position found in (1), solve for rest.

Energy minimization: dynamic programming

8Slide credit: Kristen Grauman

Page 8: Fitting a transformation: feature-based alignment Thursday, September 24 th 2015 Devi Parikh Virginia Tech 1 Slide credit: Kristen Grauman Disclaimer:

Aspects we need to consider

• Representation of the contours• Defining the energy functions

– External– Internal

• Minimizing the energy function• Extensions:

– Tracking– Interactive segmentation

9

Slide credit: Kristen Grauman

Page 9: Fitting a transformation: feature-based alignment Thursday, September 24 th 2015 Devi Parikh Virginia Tech 1 Slide credit: Kristen Grauman Disclaimer:

Tracking via deformable contours

1. Use final contour/model extracted at frame t as an initial solution for frame t+1

2. Evolve initial contour to fit exact object boundary at frame t+1

3. Repeat, initializing with most recent frame.

Tracking Heart Ventricles (multiple frames)

Kristen Grauman

10

Page 10: Fitting a transformation: feature-based alignment Thursday, September 24 th 2015 Devi Parikh Virginia Tech 1 Slide credit: Kristen Grauman Disclaimer:

Visual Dynamics Group, Dept. Engineering Science, University of Oxford.

Traffic monitoringHuman-computer interactionAnimationSurveillanceComputer assisted diagnosis in medical imaging

Applications:

Tracking via deformable contours

Kristen Grauman

11

Page 11: Fitting a transformation: feature-based alignment Thursday, September 24 th 2015 Devi Parikh Virginia Tech 1 Slide credit: Kristen Grauman Disclaimer:

3D active contours•

Jörg

en A

hlbe

rg•

http

://w

ww

.cvl

.isy.

liu.s

e/S

cOut

/Ma

ster

s/P

ape

rs/E

x170

8.p

df

Kristen Grauman

12

Page 12: Fitting a transformation: feature-based alignment Thursday, September 24 th 2015 Devi Parikh Virginia Tech 1 Slide credit: Kristen Grauman Disclaimer:

• May over-smooth the boundary

• Cannot follow topological changes of objects

Limitations

13

Slide credit: Kristen Grauman

Page 13: Fitting a transformation: feature-based alignment Thursday, September 24 th 2015 Devi Parikh Virginia Tech 1 Slide credit: Kristen Grauman Disclaimer:

Limitations• External energy: snake does not really “see” object

boundaries in the image unless it gets very close to it.

image gradientsare large only directly on the boundary

I

14

Slide credit: Kristen Grauman

Page 14: Fitting a transformation: feature-based alignment Thursday, September 24 th 2015 Devi Parikh Virginia Tech 1 Slide credit: Kristen Grauman Disclaimer:

Distance transform• External image can instead be taken from the distance

transform of the edge image.

original -gradient distance transform

edges

Value at (x,y) tells how far that position is from the nearest edge point (or other binary mage structure) >> help bwdist

Kristen Grauman

15

Page 15: Fitting a transformation: feature-based alignment Thursday, September 24 th 2015 Devi Parikh Virginia Tech 1 Slide credit: Kristen Grauman Disclaimer:

Deformable contours: pros and cons

Pros:• Useful to track and fit non-rigid shapes• Contour remains connected• Possible to fill in “subjective” contours• Flexibility in how energy function is defined, weighted.

Cons:• Must have decent initialization near true boundary, may

get stuck in local minimum• Parameters of energy function must be set well based on

prior information

Kristen Grauman

16

Page 16: Fitting a transformation: feature-based alignment Thursday, September 24 th 2015 Devi Parikh Virginia Tech 1 Slide credit: Kristen Grauman Disclaimer:

Summary

• Deformable shapes and active contours are useful for

– Segmentation: fit or “snap” to boundary in image– Tracking: previous frame’s estimate serves to initialize the next

• Fitting active contours:

– Define terms to encourage certain shapes, smoothness, low curvature, push/pulls, …

– Use weights to control relative influence of each component cost – Can optimize 2d snakes with Viterbi algorithm.

• Image structure (esp. gradients) can act as attraction force for interactive segmentation methods.

Kristen Grauman

17

Page 17: Fitting a transformation: feature-based alignment Thursday, September 24 th 2015 Devi Parikh Virginia Tech 1 Slide credit: Kristen Grauman Disclaimer:

Today

• Interactive segmentation• Feature-based alignment

– 2D transformations– Affine fit– RANSAC

18

Slide credit: Kristen Grauman

Page 18: Fitting a transformation: feature-based alignment Thursday, September 24 th 2015 Devi Parikh Virginia Tech 1 Slide credit: Kristen Grauman Disclaimer:

Today

• Interactive segmentation• Feature-based alignment

– 2D transformations– Affine fit– RANSAC

19

Slide credit: Kristen Grauman

Page 19: Fitting a transformation: feature-based alignment Thursday, September 24 th 2015 Devi Parikh Virginia Tech 1 Slide credit: Kristen Grauman Disclaimer:

Interactive forces

How can we implement such an interactive force with deformable contours?

Kristen Grauman

20

Page 20: Fitting a transformation: feature-based alignment Thursday, September 24 th 2015 Devi Parikh Virginia Tech 1 Slide credit: Kristen Grauman Disclaimer:

Interactive forces

• An energy function can be altered online based on user input – use the cursor to push or pull the initial snake away from a point.

• Modify external energy term to include a term such that

1

02

2

||

n

i ipush p

rE

Nearby points get pushed hardest

Adapted by Devi Parikh from Kristen Grauman

21

Page 21: Fitting a transformation: feature-based alignment Thursday, September 24 th 2015 Devi Parikh Virginia Tech 1 Slide credit: Kristen Grauman Disclaimer:

Intelligent scissors

[Mortensen & Barrett, SIGGRAPH 1995, CVPR 1999]

Another form of interactive segmentation:

Compute optimal paths from every point to the seed based on edge-related costs.

22

Adapted by Devi Parikh from Kristen Grauman Demo: http://www.luberth.com/java/scissors/

Page 22: Fitting a transformation: feature-based alignment Thursday, September 24 th 2015 Devi Parikh Virginia Tech 1 Slide credit: Kristen Grauman Disclaimer:

http://rivit.cs.byu.edu/Eric/Eric.html

Intelligent scissors

23

Slide credit: Kristen Grauman

Page 23: Fitting a transformation: feature-based alignment Thursday, September 24 th 2015 Devi Parikh Virginia Tech 1 Slide credit: Kristen Grauman Disclaimer:

http://rivit.cs.byu.edu/Eric/Eric.html

Intelligent scissors

24

Slide credit: Kristen Grauman

Page 24: Fitting a transformation: feature-based alignment Thursday, September 24 th 2015 Devi Parikh Virginia Tech 1 Slide credit: Kristen Grauman Disclaimer:

Beyond boundary snapping…

• Another form of interactive guidance: specify regions• Usually taken to suggest foreground/background color

distributions

Boykov and Jolly (2001)

User Input Result

How to use this information?Kristen Grauman

25

Page 25: Fitting a transformation: feature-based alignment Thursday, September 24 th 2015 Devi Parikh Virginia Tech 1 Slide credit: Kristen Grauman Disclaimer:

q

Recall: Images as graphs

Fully-connected graph• node for every pixel• link between every pair of pixels, p,q• similarity wpq for each link

» similarity is inversely proportional to difference in color and position

p

wpqw

Steve Seitz

26

Page 26: Fitting a transformation: feature-based alignment Thursday, September 24 th 2015 Devi Parikh Virginia Tech 1 Slide credit: Kristen Grauman Disclaimer:

Recall: Segmentation by Graph Cuts

Break graph into segments• Delete links that cross between segments

• Easiest to break links that have low similarity– similar pixels should be in the same segments– dissimilar pixels should be in different segments

w

A B C

Steve Seitz

27

Page 27: Fitting a transformation: feature-based alignment Thursday, September 24 th 2015 Devi Parikh Virginia Tech 1 Slide credit: Kristen Grauman Disclaimer:

Adding hard constraints:

Add two additional nodes, object and background “terminals”

Link each pixel• To both terminals• To its neighboring pixels

Graph cuts for interactive segmentation

Yuri Boykov29

Page 28: Fitting a transformation: feature-based alignment Thursday, September 24 th 2015 Devi Parikh Virginia Tech 1 Slide credit: Kristen Grauman Disclaimer:

Graph cuts for interactive segmentation

Adding hard constraints:

Let the edge weight to object or background terminal reflect similarity to the respective seed pixels.

Yuri Boykov30

Page 29: Fitting a transformation: feature-based alignment Thursday, September 24 th 2015 Devi Parikh Virginia Tech 1 Slide credit: Kristen Grauman Disclaimer:

Intelligent Scissors Mortensen and Barrett (1995)

GrabCutRother et al. (2004)

Graph Cuts Boykov and Jolly (2001)

Graph cuts for interactive segmentation

Another interaction modality: specify bounding box

32

Slide credit: Kristen Grauman

Page 30: Fitting a transformation: feature-based alignment Thursday, September 24 th 2015 Devi Parikh Virginia Tech 1 Slide credit: Kristen Grauman Disclaimer:

“Grab Cut”

• Loosely specify foreground region• Iterated graph cut

Rother et al (2004)

User Initialisation

K-means for learning

colour distributions

Graph cuts to infer the

segmentation

? User initialization

33

Page 31: Fitting a transformation: feature-based alignment Thursday, September 24 th 2015 Devi Parikh Virginia Tech 1 Slide credit: Kristen Grauman Disclaimer:

“Grab Cut”

• Loosely specify foreground region• Iterated graph cut

Rother et al (2004)Gaussian Mixture Model (typically 5-8 components)

Foreground &Background

Background

Foreground

BackgroundG

R

G

RIterated graph cut

34

Page 32: Fitting a transformation: feature-based alignment Thursday, September 24 th 2015 Devi Parikh Virginia Tech 1 Slide credit: Kristen Grauman Disclaimer:

“Grab Cut”

Rother et al (2004)35

Page 33: Fitting a transformation: feature-based alignment Thursday, September 24 th 2015 Devi Parikh Virginia Tech 1 Slide credit: Kristen Grauman Disclaimer:

Topics overview• Features & filters• Grouping & fitting

– Segmentation and clustering– Hough transform– Deformable contours– Alignment and 2D image transformations

• Multiple views and motion• Recognition• Video processing

36

Slide credit: Kristen Grauman

Page 34: Fitting a transformation: feature-based alignment Thursday, September 24 th 2015 Devi Parikh Virginia Tech 1 Slide credit: Kristen Grauman Disclaimer:

Today

• Interactive segmentation• Feature-based alignment

– 2D transformations– Affine fit– RANSAC

37

Slide credit: Kristen Grauman

Page 35: Fitting a transformation: feature-based alignment Thursday, September 24 th 2015 Devi Parikh Virginia Tech 1 Slide credit: Kristen Grauman Disclaimer:

Motivation: Recognition

Figures from David Lowe

38

Slide credit: Kristen Grauman

Page 36: Fitting a transformation: feature-based alignment Thursday, September 24 th 2015 Devi Parikh Virginia Tech 1 Slide credit: Kristen Grauman Disclaimer:

Motivation: medical image registration

39

Slide credit: Kristen Grauman

Page 37: Fitting a transformation: feature-based alignment Thursday, September 24 th 2015 Devi Parikh Virginia Tech 1 Slide credit: Kristen Grauman Disclaimer:

Motivation: mosaics

Image from http://graphics.cs.cmu.edu/courses/15-463/2010_fall/

(In detail next week)

40

Slide credit: Kristen Grauman

Page 38: Fitting a transformation: feature-based alignment Thursday, September 24 th 2015 Devi Parikh Virginia Tech 1 Slide credit: Kristen Grauman Disclaimer:

Alignment problem

• We have previously considered how to fit a model to image evidence– e.g., a line to edge points, or a snake to a deforming contour

• In alignment, we will fit the parameters of some transformation according to a set of matching feature pairs (“correspondences”).

T

xixi

'

41

Slide credit: Kristen Grauman

Page 39: Fitting a transformation: feature-based alignment Thursday, September 24 th 2015 Devi Parikh Virginia Tech 1 Slide credit: Kristen Grauman Disclaimer:

Parametric (global) warpingExamples of parametric warps:

translation rotation aspect

affineperspective

Source: Alyosha Efros

42

Page 40: Fitting a transformation: feature-based alignment Thursday, September 24 th 2015 Devi Parikh Virginia Tech 1 Slide credit: Kristen Grauman Disclaimer:

Parametric (global) warping

Transformation T is a coordinate-changing machine:

p’ = T(p)

What does it mean that T is global?• Is the same for any point p• can be described by just a few numbers (parameters)

Let’s represent T as a matrix:

p’ = Mp

T

p = (x,y) p’ = (x’,y’)

y

x

y

xM

'

'

Source: Alyosha Efros

43

Page 41: Fitting a transformation: feature-based alignment Thursday, September 24 th 2015 Devi Parikh Virginia Tech 1 Slide credit: Kristen Grauman Disclaimer:

ScalingScaling a coordinate means multiplying each of its components by

a scalarUniform scaling means this scalar is the same for all components:

2

Source: Alyosha Efros

44

Page 42: Fitting a transformation: feature-based alignment Thursday, September 24 th 2015 Devi Parikh Virginia Tech 1 Slide credit: Kristen Grauman Disclaimer:

Non-uniform scaling: different scalars per component:

Scaling

X 2,Y 0.5

Source: Alyosha Efros

45

Page 43: Fitting a transformation: feature-based alignment Thursday, September 24 th 2015 Devi Parikh Virginia Tech 1 Slide credit: Kristen Grauman Disclaimer:

Scaling

Scaling operation:

Or, in matrix form:

byy

axx

'

'

y

x

b

a

y

x

0

0

'

'

scaling matrix S

Source: Alyosha Efros

46

Page 44: Fitting a transformation: feature-based alignment Thursday, September 24 th 2015 Devi Parikh Virginia Tech 1 Slide credit: Kristen Grauman Disclaimer:

What transformations can be represented with a 2x2 matrix?

2D Rotate around (0,0)?

yxyyxx

*cos*sin'*sin*cos'

y

x

y

x

cossin

sincos

'

'

2D Shear?

yxshy

yshxx

y

x

*'

*'

y

x

sh

sh

y

x

y

x

1

1

'

'

Source: Alyosha Efros

2D Scaling?

ysy

xsx

y

x

*'

*'

y

x

s

s

y

x

y

x

0

0

'

'

47

Page 45: Fitting a transformation: feature-based alignment Thursday, September 24 th 2015 Devi Parikh Virginia Tech 1 Slide credit: Kristen Grauman Disclaimer:

What transformations can be represented with a 2x2 matrix?

Source: Alyosha Efros

2D Mirror about Y axis?

yyxx

''

yx

yx

1001

''

2D Mirror over (0,0)?

yyxx

''

yx

yx

1001

''

2D Translation?

y

x

tyy

txx

'

'NO!

48

Page 46: Fitting a transformation: feature-based alignment Thursday, September 24 th 2015 Devi Parikh Virginia Tech 1 Slide credit: Kristen Grauman Disclaimer:

2D Linear Transformations

Only linear 2D transformations can be represented with a 2x2 matrix.

Linear transformations are combinations of …• Scale,• Rotation,• Shear, and• Mirror

y

x

dc

ba

y

x

'

'

Source: Alyosha Efros

49

Page 47: Fitting a transformation: feature-based alignment Thursday, September 24 th 2015 Devi Parikh Virginia Tech 1 Slide credit: Kristen Grauman Disclaimer:

Homogeneous coordinates

Converting from homogeneous coordinates

homogeneous image coordinates

To convert to homogeneous coordinates:

50

Slide credit: Kristen Grauman

Page 48: Fitting a transformation: feature-based alignment Thursday, September 24 th 2015 Devi Parikh Virginia Tech 1 Slide credit: Kristen Grauman Disclaimer:

Homogeneous CoordinatesQ: How can we represent 2d translation as a 3x3 matrix

using homogeneous coordinates?

A: Using the rightmost column:

100

10

01

y

x

t

t

ranslationT

y

x

tyy

txx

'

'

Source: Alyosha Efros

51

Page 49: Fitting a transformation: feature-based alignment Thursday, September 24 th 2015 Devi Parikh Virginia Tech 1 Slide credit: Kristen Grauman Disclaimer:

Translation

11100

10

01

1

'

'

y

x

y

x

ty

tx

y

x

t

t

y

x

tx = 2ty = 1

Homogeneous Coordinates

Source: Alyosha Efros

52

Page 50: Fitting a transformation: feature-based alignment Thursday, September 24 th 2015 Devi Parikh Virginia Tech 1 Slide credit: Kristen Grauman Disclaimer:

Basic 2D TransformationsBasic 2D transformations as 3x3 matrices

1100

0cossin

0sincos

1

'

'

y

x

y

x

1100

10

01

1

'

'

y

x

t

t

y

x

y

x

1100

01

01

1

'

'

y

x

sh

sh

y

x

y

x

Translate

Rotate Shear

1100

00

00

1

'

'

y

x

s

s

y

x

y

x

Scale

Source: Alyosha Efros

53

Page 51: Fitting a transformation: feature-based alignment Thursday, September 24 th 2015 Devi Parikh Virginia Tech 1 Slide credit: Kristen Grauman Disclaimer:

2D Affine Transformations

Affine transformations are combinations of …• Linear transformations, and• Translations

Parallel lines remain parallel

w

y

x

fed

cba

w

y

x

100'

'

'

54

Slide credit: Kristen Grauman

Page 52: Fitting a transformation: feature-based alignment Thursday, September 24 th 2015 Devi Parikh Virginia Tech 1 Slide credit: Kristen Grauman Disclaimer:

Today

• Interactive segmentation• Feature-based alignment

– 2D transformations– Affine fit– RANSAC

55

Slide credit: Kristen Grauman

Page 53: Fitting a transformation: feature-based alignment Thursday, September 24 th 2015 Devi Parikh Virginia Tech 1 Slide credit: Kristen Grauman Disclaimer:

Alignment problem

• We have previously considered how to fit a model to image evidence– e.g., a line to edge points, or a snake to a deforming contour

• In alignment, we will fit the parameters of some transformation according to a set of matching feature pairs (“correspondences”).

T

xixi

'

Kristen Grauman

56

Page 54: Fitting a transformation: feature-based alignment Thursday, September 24 th 2015 Devi Parikh Virginia Tech 1 Slide credit: Kristen Grauman Disclaimer:

Image alignment

• Two broad approaches:– Direct (pixel-based) alignment

• Search for alignment where most pixels agree

– Feature-based alignment• Search for alignment where extracted features agree

• Can be verified using pixel-based alignment 57

Slide credit: Kristen Grauman

Page 55: Fitting a transformation: feature-based alignment Thursday, September 24 th 2015 Devi Parikh Virginia Tech 1 Slide credit: Kristen Grauman Disclaimer:

Fitting an affine transformation• Assuming we know the correspondences, how do we

get the transformation?

),( ii yx ),( ii yx

2

1

43

21

t

t

y

x

mm

mm

y

x

i

i

i

i

58

Slide credit: Kristen Grauman

Page 56: Fitting a transformation: feature-based alignment Thursday, September 24 th 2015 Devi Parikh Virginia Tech 1 Slide credit: Kristen Grauman Disclaimer:

An aside: Least Squares ExampleSay we have a set of data points (X1,X1’), (X2,X2’),

(X3,X3’), etc. (e.g. person’s height vs. weight)

We want a nice compact formula (a line) to predict X’s from Xs: Xa + b = X’

We want to find a and b

How many (X,X’) pairs do we need?

What if the data is noisy?

'22

'11

XbaX

XbaX

'2

'1

2

1

1

1

X

X

b

a

X

XAx=B

.........

1

1

1

'3

'2

'1

3

2

1

X

X

X

b

a

X

X

X

overconstrained

2min BAx

Source: Alyosha Efros

59

Page 57: Fitting a transformation: feature-based alignment Thursday, September 24 th 2015 Devi Parikh Virginia Tech 1 Slide credit: Kristen Grauman Disclaimer:

Fitting an affine transformation• Assuming we know the correspondences, how do we

get the transformation?

),( ii yx ),( ii yx

2

1

43

21

t

t

y

x

mm

mm

y

x

i

i

i

i

i

i

ii

ii

y

x

t

t

m

m

m

m

yx

yx

2

1

4

3

2

1

1000

0100

60

Slide credit: Kristen Grauman

Page 58: Fitting a transformation: feature-based alignment Thursday, September 24 th 2015 Devi Parikh Virginia Tech 1 Slide credit: Kristen Grauman Disclaimer:

Fitting an affine transformation

• How many matches (correspondence pairs) do we need to solve for the transformation parameters?

• Once we have solved for the parameters, how do we compute the coordinates of the corresponding point for ?

• Where do the matches come from?

i

i

ii

ii

y

x

t

t

m

m

m

m

yx

yx

2

1

4

3

2

1

1000

0100

),( newnew yx

Kristen Grauman

61

Page 59: Fitting a transformation: feature-based alignment Thursday, September 24 th 2015 Devi Parikh Virginia Tech 1 Slide credit: Kristen Grauman Disclaimer:

What are the correspondences?

?

• Compare content in local patches, find best matches.e.g., simplest approach: scan with template, and compute SSD or correlation between list of pixel intensities in the patch

• Later in the course: how to select regions according to the geometric changes, and more robust descriptors.

Kristen Grauman

62

Page 60: Fitting a transformation: feature-based alignment Thursday, September 24 th 2015 Devi Parikh Virginia Tech 1 Slide credit: Kristen Grauman Disclaimer:

Fitting an affine transformation

Figures from David Lowe, ICCV 1999

Affine model approximates perspective projection of planar objects.

63

Slide credit: Kristen Grauman

Page 61: Fitting a transformation: feature-based alignment Thursday, September 24 th 2015 Devi Parikh Virginia Tech 1 Slide credit: Kristen Grauman Disclaimer:

Today

• Interactive segmentation• Feature-based alignment

– 2D transformations– Affine fit– RANSAC

64

Slide credit: Kristen Grauman

Page 62: Fitting a transformation: feature-based alignment Thursday, September 24 th 2015 Devi Parikh Virginia Tech 1 Slide credit: Kristen Grauman Disclaimer:

Outliers• Outliers can hurt the quality of our parameter

estimates, e.g., – an erroneous pair of matching points from two images– an edge point that is noise, or doesn’t belong to the

line we are fitting.

Kristen Grauman

65

Page 63: Fitting a transformation: feature-based alignment Thursday, September 24 th 2015 Devi Parikh Virginia Tech 1 Slide credit: Kristen Grauman Disclaimer:

Outliers affect least squares fit

66

Slide credit: Kristen Grauman

Page 64: Fitting a transformation: feature-based alignment Thursday, September 24 th 2015 Devi Parikh Virginia Tech 1 Slide credit: Kristen Grauman Disclaimer:

Outliers affect least squares fit

67

Slide credit: Kristen Grauman

Page 65: Fitting a transformation: feature-based alignment Thursday, September 24 th 2015 Devi Parikh Virginia Tech 1 Slide credit: Kristen Grauman Disclaimer:

RANSAC

• RANdom Sample Consensus

• Approach: we want to avoid the impact of outliers, so let’s look for “inliers”, and use those only.

• Intuition: if an outlier is chosen to compute the current fit, then the resulting line won’t have much support from rest of the points.

68

Slide credit: Kristen Grauman

Page 66: Fitting a transformation: feature-based alignment Thursday, September 24 th 2015 Devi Parikh Virginia Tech 1 Slide credit: Kristen Grauman Disclaimer:

RANSAC: General form

• RANSAC loop:

1. Randomly select a seed group of points on which to base transformation estimate (e.g., a group of matches)

2. Compute transformation from seed group

3. Find inliers to this transformation

4. If the number of inliers is sufficiently large, re-compute estimate of transformation on all of the inliers

• Keep the transformation with the largest number of inliers

69

Slide credit: Kristen Grauman

Page 67: Fitting a transformation: feature-based alignment Thursday, September 24 th 2015 Devi Parikh Virginia Tech 1 Slide credit: Kristen Grauman Disclaimer:

RANSAC for line fitting example

Source: R. Raguram Lana Lazebnik

70

Page 68: Fitting a transformation: feature-based alignment Thursday, September 24 th 2015 Devi Parikh Virginia Tech 1 Slide credit: Kristen Grauman Disclaimer:

RANSAC for line fitting example

Least-squares fit

Source: R. Raguram Lana Lazebnik

71

Page 69: Fitting a transformation: feature-based alignment Thursday, September 24 th 2015 Devi Parikh Virginia Tech 1 Slide credit: Kristen Grauman Disclaimer:

RANSAC for line fitting example

1. Randomly select minimal subset of points

Source: R. Raguram Lana Lazebnik

72

Page 70: Fitting a transformation: feature-based alignment Thursday, September 24 th 2015 Devi Parikh Virginia Tech 1 Slide credit: Kristen Grauman Disclaimer:

RANSAC for line fitting example

1. Randomly select minimal subset of points

2. Hypothesize a model

Source: R. Raguram Lana Lazebnik

73

Page 71: Fitting a transformation: feature-based alignment Thursday, September 24 th 2015 Devi Parikh Virginia Tech 1 Slide credit: Kristen Grauman Disclaimer:

RANSAC for line fitting example

1. Randomly select minimal subset of points

2. Hypothesize a model

3. Compute error function

Source: R. Raguram Lana Lazebnik

74

Page 72: Fitting a transformation: feature-based alignment Thursday, September 24 th 2015 Devi Parikh Virginia Tech 1 Slide credit: Kristen Grauman Disclaimer:

RANSAC for line fitting example

1. Randomly select minimal subset of points

2. Hypothesize a model

3. Compute error function

4. Select points consistent with model

Source: R. Raguram Lana Lazebnik

75

Page 73: Fitting a transformation: feature-based alignment Thursday, September 24 th 2015 Devi Parikh Virginia Tech 1 Slide credit: Kristen Grauman Disclaimer:

RANSAC for line fitting example

1. Randomly select minimal subset of points

2. Hypothesize a model

3. Compute error function

4. Select points consistent with model

5. Repeat hypothesize-and-verify loop

Source: R. Raguram Lana Lazebnik

76

Page 74: Fitting a transformation: feature-based alignment Thursday, September 24 th 2015 Devi Parikh Virginia Tech 1 Slide credit: Kristen Grauman Disclaimer:

77

RANSAC for line fitting example

1. Randomly select minimal subset of points

2. Hypothesize a model

3. Compute error function

4. Select points consistent with model

5. Repeat hypothesize-and-verify loop

Source: R. Raguram Lana Lazebnik

Page 75: Fitting a transformation: feature-based alignment Thursday, September 24 th 2015 Devi Parikh Virginia Tech 1 Slide credit: Kristen Grauman Disclaimer:

78

RANSAC for line fitting example

1. Randomly select minimal subset of points

2. Hypothesize a model

3. Compute error function

4. Select points consistent with model

5. Repeat hypothesize-and-verify loop

Uncontaminated sample

Source: R. Raguram Lana Lazebnik

Page 76: Fitting a transformation: feature-based alignment Thursday, September 24 th 2015 Devi Parikh Virginia Tech 1 Slide credit: Kristen Grauman Disclaimer:

RANSAC for line fitting example

1. Randomly select minimal subset of points

2. Hypothesize a model

3. Compute error function

4. Select points consistent with model

5. Repeat hypothesize-and-verify loop

Source: R. Raguram Lana Lazebnik

79

Page 77: Fitting a transformation: feature-based alignment Thursday, September 24 th 2015 Devi Parikh Virginia Tech 1 Slide credit: Kristen Grauman Disclaimer:

RANSAC for line fitting

Repeat N times:• Draw s points uniformly at random• Fit line to these s points• Find inliers to this line among the remaining

points (i.e., points whose distance from the line is less than t)

• If there are d or more inliers, accept the line and refit using all inliers

Lana Lazebnik

80

Page 78: Fitting a transformation: feature-based alignment Thursday, September 24 th 2015 Devi Parikh Virginia Tech 1 Slide credit: Kristen Grauman Disclaimer:

RANSAC pros and cons• Pros

• Simple and general• Applicable to many different problems• Often works well in practice

• Cons• Lots of parameters to tune• Doesn’t work well for low inlier ratios (too many iterations,

or can fail completely)• Can’t always get a good initialization

of the model based on the minimum number of samples

Lana Lazebnik

81

Page 79: Fitting a transformation: feature-based alignment Thursday, September 24 th 2015 Devi Parikh Virginia Tech 1 Slide credit: Kristen Grauman Disclaimer:

Today

• Interactive segmentation• Feature-based alignment

– 2D transformations– Affine fit– RANSAC

82

Slide credit: Kristen Grauman

Page 80: Fitting a transformation: feature-based alignment Thursday, September 24 th 2015 Devi Parikh Virginia Tech 1 Slide credit: Kristen Grauman Disclaimer:

Coming up: alignment and image stitching

83Slide credit: Kristen Grauman

Page 81: Fitting a transformation: feature-based alignment Thursday, September 24 th 2015 Devi Parikh Virginia Tech 1 Slide credit: Kristen Grauman Disclaimer:

Questions?

See you Tuesday!

84Slide credit: Devi Parikh