Computer Vision: Image Alignmenturtasun/courses/CV/lecture06.pdf · Readings Chapter 2.1, 3.6, 4.3...

125
Computer Vision: Image Alignment Raquel Urtasun TTI Chicago Jan 24, 2013 Raquel Urtasun (TTI-C) Computer Vision Jan 24, 2013 1 / 44

Transcript of Computer Vision: Image Alignmenturtasun/courses/CV/lecture06.pdf · Readings Chapter 2.1, 3.6, 4.3...

Page 1: Computer Vision: Image Alignmenturtasun/courses/CV/lecture06.pdf · Readings Chapter 2.1, 3.6, 4.3 and 6.1 of Szeliski’s book Chapter 1 of Forsyth & Ponce Raquel Urtasun (TTI-C)

Computer Vision: Image Alignment

Raquel Urtasun

TTI Chicago

Jan 24, 2013

Raquel Urtasun (TTI-C) Computer Vision Jan 24, 2013 1 / 44

Page 2: Computer Vision: Image Alignmenturtasun/courses/CV/lecture06.pdf · Readings Chapter 2.1, 3.6, 4.3 and 6.1 of Szeliski’s book Chapter 1 of Forsyth & Ponce Raquel Urtasun (TTI-C)

Readings

Chapter 2.1, 3.6, 4.3 and 6.1 of Szeliski’s book

Chapter 1 of Forsyth & Ponce

Raquel Urtasun (TTI-C) Computer Vision Jan 24, 2013 2 / 44

Page 3: Computer Vision: Image Alignmenturtasun/courses/CV/lecture06.pdf · Readings Chapter 2.1, 3.6, 4.3 and 6.1 of Szeliski’s book Chapter 1 of Forsyth & Ponce Raquel Urtasun (TTI-C)

What did we see in class last week?

Raquel Urtasun (TTI-C) Computer Vision Jan 24, 2013 3 / 44

Page 4: Computer Vision: Image Alignmenturtasun/courses/CV/lecture06.pdf · Readings Chapter 2.1, 3.6, 4.3 and 6.1 of Szeliski’s book Chapter 1 of Forsyth & Ponce Raquel Urtasun (TTI-C)

What is the geometric relationship between these images?

!"

[Source: N. Snavely]

Raquel Urtasun (TTI-C) Computer Vision Jan 24, 2013 4 / 44

Page 5: Computer Vision: Image Alignmenturtasun/courses/CV/lecture06.pdf · Readings Chapter 2.1, 3.6, 4.3 and 6.1 of Szeliski’s book Chapter 1 of Forsyth & Ponce Raquel Urtasun (TTI-C)

What is the geometric relationship between these images?

Very important for creating mosaics!

[Source: N. Snavely]

Raquel Urtasun (TTI-C) Computer Vision Jan 24, 2013 4 / 44

Page 6: Computer Vision: Image Alignmenturtasun/courses/CV/lecture06.pdf · Readings Chapter 2.1, 3.6, 4.3 and 6.1 of Szeliski’s book Chapter 1 of Forsyth & Ponce Raquel Urtasun (TTI-C)

Image Warping

Image filtering: change range of image

g(x) = h(f (x))

!"

#"

$"%"

#"

Image warping: change domain of image

g(x) = f (h(x))

!"

#"

$"%"

#"

[Source: R. Szeliski]Raquel Urtasun (TTI-C) Computer Vision Jan 24, 2013 5 / 44

Page 7: Computer Vision: Image Alignmenturtasun/courses/CV/lecture06.pdf · Readings Chapter 2.1, 3.6, 4.3 and 6.1 of Szeliski’s book Chapter 1 of Forsyth & Ponce Raquel Urtasun (TTI-C)

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 pCan be described by just a few numbers (parameters)

[Source: N. Snavely]

Raquel Urtasun (TTI-C) Computer Vision Jan 24, 2013 6 / 44

Page 8: Computer Vision: Image Alignmenturtasun/courses/CV/lecture06.pdf · Readings Chapter 2.1, 3.6, 4.3 and 6.1 of Szeliski’s book Chapter 1 of Forsyth & Ponce Raquel Urtasun (TTI-C)

Forward and Inverse Warping

Forward Warping: Send each pixel f (x) to its corresponding location(x ′, y ′) = T (x , y) in g(x ′, y ′)

Inverse Warping: Each pixel at the destination is sampled from the originalimage

Raquel Urtasun (TTI-C) Computer Vision Jan 24, 2013 7 / 44

Page 9: Computer Vision: Image Alignmenturtasun/courses/CV/lecture06.pdf · Readings Chapter 2.1, 3.6, 4.3 and 6.1 of Szeliski’s book Chapter 1 of Forsyth & Ponce Raquel Urtasun (TTI-C)

All 2D Linear Transformations

Linear transformations are combinations of

Scale,

Rotation

Shear

Mirror [x ′

y ′

]=

[a bc d

] [xy

][Source: N. Snavely]

Raquel Urtasun (TTI-C) Computer Vision Jan 24, 2013 8 / 44

Page 10: Computer Vision: Image Alignmenturtasun/courses/CV/lecture06.pdf · Readings Chapter 2.1, 3.6, 4.3 and 6.1 of Szeliski’s book Chapter 1 of Forsyth & Ponce Raquel Urtasun (TTI-C)

All 2D Linear Transformations

Properties of linear transformations:

Origin maps to origin

Lines map to lines

Parallel lines remain parallel

Ratios are preserved

Closed under composition[x ′

y ′

]=

[a bc d

] [e fg h

] [i jk l

] [xy

]What about the translation?

[Source: N. Snavely]

Raquel Urtasun (TTI-C) Computer Vision Jan 24, 2013 9 / 44

Page 11: Computer Vision: Image Alignmenturtasun/courses/CV/lecture06.pdf · Readings Chapter 2.1, 3.6, 4.3 and 6.1 of Szeliski’s book Chapter 1 of Forsyth & Ponce Raquel Urtasun (TTI-C)

All 2D Linear Transformations

Properties of linear transformations:

Origin maps to origin

Lines map to lines

Parallel lines remain parallel

Ratios are preserved

Closed under composition[x ′

y ′

]=

[a bc d

] [e fg h

] [i jk l

] [xy

]What about the translation?

[Source: N. Snavely]

Raquel Urtasun (TTI-C) Computer Vision Jan 24, 2013 9 / 44

Page 12: Computer Vision: Image Alignmenturtasun/courses/CV/lecture06.pdf · Readings Chapter 2.1, 3.6, 4.3 and 6.1 of Szeliski’s book Chapter 1 of Forsyth & Ponce Raquel Urtasun (TTI-C)

All 2D Linear Transformations

Properties of linear transformations:

Origin maps to origin

Lines map to lines

Parallel lines remain parallel

Ratios are preserved

Closed under composition[x ′

y ′

]=

[a bc d

] [e fg h

] [i jk l

] [xy

]What about the translation?

[Source: N. Snavely]

Raquel Urtasun (TTI-C) Computer Vision Jan 24, 2013 9 / 44

Page 13: Computer Vision: Image Alignmenturtasun/courses/CV/lecture06.pdf · Readings Chapter 2.1, 3.6, 4.3 and 6.1 of Szeliski’s book Chapter 1 of Forsyth & Ponce Raquel Urtasun (TTI-C)

All 2D Linear Transformations

Properties of linear transformations:

Origin maps to origin

Lines map to lines

Parallel lines remain parallel

Ratios are preserved

Closed under composition[x ′

y ′

]=

[a bc d

] [e fg h

] [i jk l

] [xy

]

What about the translation?

[Source: N. Snavely]

Raquel Urtasun (TTI-C) Computer Vision Jan 24, 2013 9 / 44

Page 14: Computer Vision: Image Alignmenturtasun/courses/CV/lecture06.pdf · Readings Chapter 2.1, 3.6, 4.3 and 6.1 of Szeliski’s book Chapter 1 of Forsyth & Ponce Raquel Urtasun (TTI-C)

All 2D Linear Transformations

Properties of linear transformations:

Origin maps to origin

Lines map to lines

Parallel lines remain parallel

Ratios are preserved

Closed under composition[x ′

y ′

]=

[a bc d

] [e fg h

] [i jk l

] [xy

]What about the translation?

[Source: N. Snavely]

Raquel Urtasun (TTI-C) Computer Vision Jan 24, 2013 9 / 44

Page 15: Computer Vision: Image Alignmenturtasun/courses/CV/lecture06.pdf · Readings Chapter 2.1, 3.6, 4.3 and 6.1 of Szeliski’s book Chapter 1 of Forsyth & Ponce Raquel Urtasun (TTI-C)

All 2D Linear Transformations

Properties of linear transformations:

Origin maps to origin

Lines map to lines

Parallel lines remain parallel

Ratios are preserved

Closed under composition[x ′

y ′

]=

[a bc d

] [e fg h

] [i jk l

] [xy

]What about the translation?

[Source: N. Snavely]

Raquel Urtasun (TTI-C) Computer Vision Jan 24, 2013 9 / 44

Page 16: Computer Vision: Image Alignmenturtasun/courses/CV/lecture06.pdf · Readings Chapter 2.1, 3.6, 4.3 and 6.1 of Szeliski’s book Chapter 1 of Forsyth & Ponce Raquel Urtasun (TTI-C)

Affine Transformations

Affine transformations are combinations of

Linear transformations, and

Translations x ′y ′w

=

a b cd e f0 0 1

xyw

Properties of affine transformations:

Origin does not necessarily map to origin

Lines map to lines

Parallel lines remain parallel

Ratios are preserved

Closed under composition

[Source: N. Snavely]

Raquel Urtasun (TTI-C) Computer Vision Jan 24, 2013 10 / 44

Page 17: Computer Vision: Image Alignmenturtasun/courses/CV/lecture06.pdf · Readings Chapter 2.1, 3.6, 4.3 and 6.1 of Szeliski’s book Chapter 1 of Forsyth & Ponce Raquel Urtasun (TTI-C)

Projective Transformations

Affine transformations and Projective warpsx ′y ′w ′

=

a b cd e fg h i

xyw

Properties of affine transformations:

Origin does not necessarily map to origin

Lines map to lines

Parallel lines do not necessarily remain parallel

Ratios are not preserved

Closed under composition

[Source: N. Snavely]

Raquel Urtasun (TTI-C) Computer Vision Jan 24, 2013 11 / 44

Page 18: Computer Vision: Image Alignmenturtasun/courses/CV/lecture06.pdf · Readings Chapter 2.1, 3.6, 4.3 and 6.1 of Szeliski’s book Chapter 1 of Forsyth & Ponce Raquel Urtasun (TTI-C)

2D Image Tranformations

These transformations are a nested set of groups

Closed under composition and inverse is a member

Raquel Urtasun (TTI-C) Computer Vision Jan 24, 2013 12 / 44

Page 19: Computer Vision: Image Alignmenturtasun/courses/CV/lecture06.pdf · Readings Chapter 2.1, 3.6, 4.3 and 6.1 of Szeliski’s book Chapter 1 of Forsyth & Ponce Raquel Urtasun (TTI-C)

Computing transformations

Given a set of matches between images A and B

How can we compute the transform T from A to B?

Find transform T that best agrees with the matches

[Source: N. Snavely]Raquel Urtasun (TTI-C) Computer Vision Jan 24, 2013 13 / 44

Page 20: Computer Vision: Image Alignmenturtasun/courses/CV/lecture06.pdf · Readings Chapter 2.1, 3.6, 4.3 and 6.1 of Szeliski’s book Chapter 1 of Forsyth & Ponce Raquel Urtasun (TTI-C)

Least squares formulation

For each point (xi , yi ) we have

xi + xt = x ′iyi + yt = y ′i

We define the residuals as

rxi (xt) = xi + xt − x ′iryi (yt) = yi + yt − y ′i

Goal: minimize sum of squared residuals

C (xt , yt) =n∑

i=1

(rxi (xt)2 + ryi (yt)

2)

The solution is called the least squares solution

For translations, is equal to mean displacement

[Source: N. Snavely]

Raquel Urtasun (TTI-C) Computer Vision Jan 24, 2013 14 / 44

Page 21: Computer Vision: Image Alignmenturtasun/courses/CV/lecture06.pdf · Readings Chapter 2.1, 3.6, 4.3 and 6.1 of Szeliski’s book Chapter 1 of Forsyth & Ponce Raquel Urtasun (TTI-C)

Least squares formulation

For each point (xi , yi ) we have

xi + xt = x ′iyi + yt = y ′i

We define the residuals as

rxi (xt) = xi + xt − x ′iryi (yt) = yi + yt − y ′i

Goal: minimize sum of squared residuals

C (xt , yt) =n∑

i=1

(rxi (xt)2 + ryi (yt)

2)

The solution is called the least squares solution

For translations, is equal to mean displacement

[Source: N. Snavely]

Raquel Urtasun (TTI-C) Computer Vision Jan 24, 2013 14 / 44

Page 22: Computer Vision: Image Alignmenturtasun/courses/CV/lecture06.pdf · Readings Chapter 2.1, 3.6, 4.3 and 6.1 of Szeliski’s book Chapter 1 of Forsyth & Ponce Raquel Urtasun (TTI-C)

Least squares formulation

For each point (xi , yi ) we have

xi + xt = x ′iyi + yt = y ′i

We define the residuals as

rxi (xt) = xi + xt − x ′iryi (yt) = yi + yt − y ′i

Goal: minimize sum of squared residuals

C (xt , yt) =n∑

i=1

(rxi (xt)2 + ryi (yt)

2)

The solution is called the least squares solution

For translations, is equal to mean displacement

[Source: N. Snavely]

Raquel Urtasun (TTI-C) Computer Vision Jan 24, 2013 14 / 44

Page 23: Computer Vision: Image Alignmenturtasun/courses/CV/lecture06.pdf · Readings Chapter 2.1, 3.6, 4.3 and 6.1 of Szeliski’s book Chapter 1 of Forsyth & Ponce Raquel Urtasun (TTI-C)

Least squares formulation

For each point (xi , yi ) we have

xi + xt = x ′iyi + yt = y ′i

We define the residuals as

rxi (xt) = xi + xt − x ′iryi (yt) = yi + yt − y ′i

Goal: minimize sum of squared residuals

C (xt , yt) =n∑

i=1

(rxi (xt)2 + ryi (yt)

2)

The solution is called the least squares solution

For translations, is equal to mean displacement

[Source: N. Snavely]

Raquel Urtasun (TTI-C) Computer Vision Jan 24, 2013 14 / 44

Page 24: Computer Vision: Image Alignmenturtasun/courses/CV/lecture06.pdf · Readings Chapter 2.1, 3.6, 4.3 and 6.1 of Szeliski’s book Chapter 1 of Forsyth & Ponce Raquel Urtasun (TTI-C)

Least squares formulation

For each point (xi , yi ) we have

xi + xt = x ′iyi + yt = y ′i

We define the residuals as

rxi (xt) = xi + xt − x ′iryi (yt) = yi + yt − y ′i

Goal: minimize sum of squared residuals

C (xt , yt) =n∑

i=1

(rxi (xt)2 + ryi (yt)

2)

The solution is called the least squares solution

For translations, is equal to mean displacement

[Source: N. Snavely]Raquel Urtasun (TTI-C) Computer Vision Jan 24, 2013 14 / 44

Page 25: Computer Vision: Image Alignmenturtasun/courses/CV/lecture06.pdf · Readings Chapter 2.1, 3.6, 4.3 and 6.1 of Szeliski’s book Chapter 1 of Forsyth & Ponce Raquel Urtasun (TTI-C)

Least squares formulation

For each point (xi , yi ) we have

xi + xt = x ′iyi + yt = y ′i

We define the residuals as

rxi (xt) = xi + xt − x ′iryi (yt) = yi + yt − y ′i

Goal: minimize sum of squared residuals

C (xt , yt) =n∑

i=1

(rxi (xt)2 + ryi (yt)

2)

The solution is called the least squares solution

For translations, is equal to mean displacement

[Source: N. Snavely]Raquel Urtasun (TTI-C) Computer Vision Jan 24, 2013 14 / 44

Page 26: Computer Vision: Image Alignmenturtasun/courses/CV/lecture06.pdf · Readings Chapter 2.1, 3.6, 4.3 and 6.1 of Szeliski’s book Chapter 1 of Forsyth & Ponce Raquel Urtasun (TTI-C)

Matrix Formulation

We can also write as a matrix equation

!!""#!# !""#$# !!""#$#

Solve for t by looking at the fixed-point equation

Raquel Urtasun (TTI-C) Computer Vision Jan 24, 2013 15 / 44

Page 27: Computer Vision: Image Alignmenturtasun/courses/CV/lecture06.pdf · Readings Chapter 2.1, 3.6, 4.3 and 6.1 of Szeliski’s book Chapter 1 of Forsyth & Ponce Raquel Urtasun (TTI-C)

Affine Transformations

When we are dealing with an affine transformationx ′y ′w ′

=

a b cd e f0 0 1

xyw

How many unknowns?

How many equations per match?

How many matches do we need?

Why to use more?

[Source: N. Snavely]

Raquel Urtasun (TTI-C) Computer Vision Jan 24, 2013 16 / 44

Page 28: Computer Vision: Image Alignmenturtasun/courses/CV/lecture06.pdf · Readings Chapter 2.1, 3.6, 4.3 and 6.1 of Szeliski’s book Chapter 1 of Forsyth & Ponce Raquel Urtasun (TTI-C)

Affine Transformations

When we are dealing with an affine transformationx ′y ′w ′

=

a b cd e f0 0 1

xyw

How many unknowns?

How many equations per match?

How many matches do we need?

Why to use more?

[Source: N. Snavely]

Raquel Urtasun (TTI-C) Computer Vision Jan 24, 2013 16 / 44

Page 29: Computer Vision: Image Alignmenturtasun/courses/CV/lecture06.pdf · Readings Chapter 2.1, 3.6, 4.3 and 6.1 of Szeliski’s book Chapter 1 of Forsyth & Ponce Raquel Urtasun (TTI-C)

Affine Transformations

When we are dealing with an affine transformationx ′y ′w ′

=

a b cd e f0 0 1

xyw

How many unknowns?

How many equations per match?

How many matches do we need?

Why to use more?

[Source: N. Snavely]

Raquel Urtasun (TTI-C) Computer Vision Jan 24, 2013 16 / 44

Page 30: Computer Vision: Image Alignmenturtasun/courses/CV/lecture06.pdf · Readings Chapter 2.1, 3.6, 4.3 and 6.1 of Szeliski’s book Chapter 1 of Forsyth & Ponce Raquel Urtasun (TTI-C)

Affine Transformations

When we are dealing with an affine transformationx ′y ′w ′

=

a b cd e f0 0 1

xyw

How many unknowns?

How many equations per match?

How many matches do we need?

Why to use more?

[Source: N. Snavely]

Raquel Urtasun (TTI-C) Computer Vision Jan 24, 2013 16 / 44

Page 31: Computer Vision: Image Alignmenturtasun/courses/CV/lecture06.pdf · Readings Chapter 2.1, 3.6, 4.3 and 6.1 of Szeliski’s book Chapter 1 of Forsyth & Ponce Raquel Urtasun (TTI-C)

Affine Transformations

When we are dealing with an affine transformationx ′y ′w ′

=

a b cd e f0 0 1

xyw

How many unknowns?

How many equations per match?

How many matches do we need?

Why to use more?

[Source: N. Snavely]

Raquel Urtasun (TTI-C) Computer Vision Jan 24, 2013 16 / 44

Page 32: Computer Vision: Image Alignmenturtasun/courses/CV/lecture06.pdf · Readings Chapter 2.1, 3.6, 4.3 and 6.1 of Szeliski’s book Chapter 1 of Forsyth & Ponce Raquel Urtasun (TTI-C)

Affine Transformation Cost Function

We can write the residuals as

rxi (a, b, c , d , e, f ) = (axi + byi + c)− x ′iryi (a, b, c , d , e, f ) = (dxi + eyi + f )− y ′i

Cost function

C (a, b, c , d , e, f ) =N∑i=1

(rxi (a, b, c , d , e, f )2 + ryi (a, b, c , d , e, f )2

)

And in matrix form ...

[Source: N. Snavely]

Raquel Urtasun (TTI-C) Computer Vision Jan 24, 2013 17 / 44

Page 33: Computer Vision: Image Alignmenturtasun/courses/CV/lecture06.pdf · Readings Chapter 2.1, 3.6, 4.3 and 6.1 of Szeliski’s book Chapter 1 of Forsyth & Ponce Raquel Urtasun (TTI-C)

Affine Transformation Cost Function

We can write the residuals as

rxi (a, b, c , d , e, f ) = (axi + byi + c)− x ′iryi (a, b, c , d , e, f ) = (dxi + eyi + f )− y ′i

Cost function

C (a, b, c , d , e, f ) =N∑i=1

(rxi (a, b, c , d , e, f )2 + ryi (a, b, c , d , e, f )2

)

And in matrix form ...

[Source: N. Snavely]

Raquel Urtasun (TTI-C) Computer Vision Jan 24, 2013 17 / 44

Page 34: Computer Vision: Image Alignmenturtasun/courses/CV/lecture06.pdf · Readings Chapter 2.1, 3.6, 4.3 and 6.1 of Szeliski’s book Chapter 1 of Forsyth & Ponce Raquel Urtasun (TTI-C)

Affine Transformation Cost Function

We can write the residuals as

rxi (a, b, c , d , e, f ) = (axi + byi + c)− x ′iryi (a, b, c , d , e, f ) = (dxi + eyi + f )− y ′i

Cost function

C (a, b, c , d , e, f ) =N∑i=1

(rxi (a, b, c , d , e, f )2 + ryi (a, b, c , d , e, f )2

)

And in matrix form ...

[Source: N. Snavely]

Raquel Urtasun (TTI-C) Computer Vision Jan 24, 2013 17 / 44

Page 35: Computer Vision: Image Alignmenturtasun/courses/CV/lecture06.pdf · Readings Chapter 2.1, 3.6, 4.3 and 6.1 of Szeliski’s book Chapter 1 of Forsyth & Ponce Raquel Urtasun (TTI-C)

Matrix form

!!""#$# $""#%# !!""#%#

[Source: N. Snavely]

Raquel Urtasun (TTI-C) Computer Vision Jan 24, 2013 18 / 44

Page 36: Computer Vision: Image Alignmenturtasun/courses/CV/lecture06.pdf · Readings Chapter 2.1, 3.6, 4.3 and 6.1 of Szeliski’s book Chapter 1 of Forsyth & Ponce Raquel Urtasun (TTI-C)

General Formulation

Let x ′ = f (x ; p) be a parametric transformation

In the case of translation, similarity and affine, there is a linear relationshipbetween the amount of motion ∆x = x ′ − x and the unknown parameters

∆x = x ′ − x = J(x)p

with J = ∂f∂p is the Jacobian of the transformation f with respect to the

motion parameters p

Raquel Urtasun (TTI-C) Computer Vision Jan 24, 2013 19 / 44

Page 37: Computer Vision: Image Alignmenturtasun/courses/CV/lecture06.pdf · Readings Chapter 2.1, 3.6, 4.3 and 6.1 of Szeliski’s book Chapter 1 of Forsyth & Ponce Raquel Urtasun (TTI-C)

General Formulation

Let x ′ = f (x ; p) be a parametric transformation

In the case of translation, similarity and affine, there is a linear relationshipbetween the amount of motion ∆x = x ′ − x and the unknown parameters

∆x = x ′ − x = J(x)p

with J = ∂f∂p is the Jacobian of the transformation f with respect to the

motion parameters p

Raquel Urtasun (TTI-C) Computer Vision Jan 24, 2013 19 / 44

Page 38: Computer Vision: Image Alignmenturtasun/courses/CV/lecture06.pdf · Readings Chapter 2.1, 3.6, 4.3 and 6.1 of Szeliski’s book Chapter 1 of Forsyth & Ponce Raquel Urtasun (TTI-C)

General Formulation

Let’s do a couple on the board!

Raquel Urtasun (TTI-C) Computer Vision Jan 24, 2013 20 / 44

Page 39: Computer Vision: Image Alignmenturtasun/courses/CV/lecture06.pdf · Readings Chapter 2.1, 3.6, 4.3 and 6.1 of Szeliski’s book Chapter 1 of Forsyth & Ponce Raquel Urtasun (TTI-C)

General Formulation

The sum of square residuals is then

ELLS =∑i

||J(xi )p−∆xi ||22

= pT [∑i

JT (xi )J(xi )]p− 2pT [∑i

JT (xi )∆xi )] +∑i

||∆xi ||2

= pTAp− 2pTb + c

We can compute the solution by looking for a fixed point, yielding

Ap = b

with A =∑

i JT (xi )J(xi ) the Hessian and b =∑

i JT (xi )∆xi

Raquel Urtasun (TTI-C) Computer Vision Jan 24, 2013 21 / 44

Page 40: Computer Vision: Image Alignmenturtasun/courses/CV/lecture06.pdf · Readings Chapter 2.1, 3.6, 4.3 and 6.1 of Szeliski’s book Chapter 1 of Forsyth & Ponce Raquel Urtasun (TTI-C)

General Formulation

The sum of square residuals is then

ELLS =∑i

||J(xi )p−∆xi ||22

= pT [∑i

JT (xi )J(xi )]p− 2pT [∑i

JT (xi )∆xi )] +∑i

||∆xi ||2

= pTAp− 2pTb + c

We can compute the solution by looking for a fixed point, yielding

Ap = b

with A =∑

i JT (xi )J(xi ) the Hessian and b =∑

i JT (xi )∆xi

Raquel Urtasun (TTI-C) Computer Vision Jan 24, 2013 21 / 44

Page 41: Computer Vision: Image Alignmenturtasun/courses/CV/lecture06.pdf · Readings Chapter 2.1, 3.6, 4.3 and 6.1 of Szeliski’s book Chapter 1 of Forsyth & Ponce Raquel Urtasun (TTI-C)

General Formulation

The sum of square residuals is then

ELLS =∑i

||J(xi )p−∆xi ||22

= pT [∑i

JT (xi )J(xi )]p− 2pT [∑i

JT (xi )∆xi )] +∑i

||∆xi ||2

= pTAp− 2pTb + c

We can compute the solution by looking for a fixed point, yielding

Ap = b

with A =∑

i JT (xi )J(xi ) the Hessian and b =∑

i JT (xi )∆xi

Raquel Urtasun (TTI-C) Computer Vision Jan 24, 2013 21 / 44

Page 42: Computer Vision: Image Alignmenturtasun/courses/CV/lecture06.pdf · Readings Chapter 2.1, 3.6, 4.3 and 6.1 of Szeliski’s book Chapter 1 of Forsyth & Ponce Raquel Urtasun (TTI-C)

General Formulation

The sum of square residuals is then

ELLS =∑i

||J(xi )p−∆xi ||22

= pT [∑i

JT (xi )J(xi )]p− 2pT [∑i

JT (xi )∆xi )] +∑i

||∆xi ||2

= pTAp− 2pTb + c

We can compute the solution by looking for a fixed point, yielding

Ap = b

with A =∑

i JT (xi )J(xi ) the Hessian and b =∑

i JT (xi )∆xi

Raquel Urtasun (TTI-C) Computer Vision Jan 24, 2013 21 / 44

Page 43: Computer Vision: Image Alignmenturtasun/courses/CV/lecture06.pdf · Readings Chapter 2.1, 3.6, 4.3 and 6.1 of Szeliski’s book Chapter 1 of Forsyth & Ponce Raquel Urtasun (TTI-C)

Uncertainty Weighting

The above solution assumes that all feature points are matched with sameaccuracy.

If we associate a scalar variance σ2i with each correspondence, we can

minimize the weighted least squares problem

EWLS =∑i

σ−2i ||ri ||22

If the σ2i are fixed, then the solution is simply

p = (ΣTATAΣ)−1ΣTAb

with Σ, the matrix containing for each observation the noise level

What if we don’t know Σ?

Solve using iteratively reweighted least squares (IRLS)

Raquel Urtasun (TTI-C) Computer Vision Jan 24, 2013 22 / 44

Page 44: Computer Vision: Image Alignmenturtasun/courses/CV/lecture06.pdf · Readings Chapter 2.1, 3.6, 4.3 and 6.1 of Szeliski’s book Chapter 1 of Forsyth & Ponce Raquel Urtasun (TTI-C)

Uncertainty Weighting

The above solution assumes that all feature points are matched with sameaccuracy.

If we associate a scalar variance σ2i with each correspondence, we can

minimize the weighted least squares problem

EWLS =∑i

σ−2i ||ri ||22

If the σ2i are fixed, then the solution is simply

p = (ΣTATAΣ)−1ΣTAb

with Σ, the matrix containing for each observation the noise level

What if we don’t know Σ?

Solve using iteratively reweighted least squares (IRLS)

Raquel Urtasun (TTI-C) Computer Vision Jan 24, 2013 22 / 44

Page 45: Computer Vision: Image Alignmenturtasun/courses/CV/lecture06.pdf · Readings Chapter 2.1, 3.6, 4.3 and 6.1 of Szeliski’s book Chapter 1 of Forsyth & Ponce Raquel Urtasun (TTI-C)

Uncertainty Weighting

The above solution assumes that all feature points are matched with sameaccuracy.

If we associate a scalar variance σ2i with each correspondence, we can

minimize the weighted least squares problem

EWLS =∑i

σ−2i ||ri ||22

If the σ2i are fixed, then the solution is simply

p = (ΣTATAΣ)−1ΣTAb

with Σ, the matrix containing for each observation the noise level

What if we don’t know Σ?

Solve using iteratively reweighted least squares (IRLS)

Raquel Urtasun (TTI-C) Computer Vision Jan 24, 2013 22 / 44

Page 46: Computer Vision: Image Alignmenturtasun/courses/CV/lecture06.pdf · Readings Chapter 2.1, 3.6, 4.3 and 6.1 of Szeliski’s book Chapter 1 of Forsyth & Ponce Raquel Urtasun (TTI-C)

Uncertainty Weighting

The above solution assumes that all feature points are matched with sameaccuracy.

If we associate a scalar variance σ2i with each correspondence, we can

minimize the weighted least squares problem

EWLS =∑i

σ−2i ||ri ||22

If the σ2i are fixed, then the solution is simply

p = (ΣTATAΣ)−1ΣTAb

with Σ, the matrix containing for each observation the noise level

What if we don’t know Σ?

Solve using iteratively reweighted least squares (IRLS)

Raquel Urtasun (TTI-C) Computer Vision Jan 24, 2013 22 / 44

Page 47: Computer Vision: Image Alignmenturtasun/courses/CV/lecture06.pdf · Readings Chapter 2.1, 3.6, 4.3 and 6.1 of Szeliski’s book Chapter 1 of Forsyth & Ponce Raquel Urtasun (TTI-C)

Uncertainty Weighting

The above solution assumes that all feature points are matched with sameaccuracy.

If we associate a scalar variance σ2i with each correspondence, we can

minimize the weighted least squares problem

EWLS =∑i

σ−2i ||ri ||22

If the σ2i are fixed, then the solution is simply

p = (ΣTATAΣ)−1ΣTAb

with Σ, the matrix containing for each observation the noise level

What if we don’t know Σ?

Solve using iteratively reweighted least squares (IRLS)

Raquel Urtasun (TTI-C) Computer Vision Jan 24, 2013 22 / 44

Page 48: Computer Vision: Image Alignmenturtasun/courses/CV/lecture06.pdf · Readings Chapter 2.1, 3.6, 4.3 and 6.1 of Szeliski’s book Chapter 1 of Forsyth & Ponce Raquel Urtasun (TTI-C)

Homographies

!"!#"

To unwarp (rectify) and image

solve for homography H given p and p′

solve equations of the form: wp′ = Hp

linear in unknowns: w and coefficients of HH is defined up to an arbitrary scale factorhow many points are necessary to solve for H?

[Source: N. Snavely]

Raquel Urtasun (TTI-C) Computer Vision Jan 24, 2013 23 / 44

Page 49: Computer Vision: Image Alignmenturtasun/courses/CV/lecture06.pdf · Readings Chapter 2.1, 3.6, 4.3 and 6.1 of Szeliski’s book Chapter 1 of Forsyth & Ponce Raquel Urtasun (TTI-C)

Homographies

!"!#"

To unwarp (rectify) and image

solve for homography H given p and p′

solve equations of the form: wp′ = Hp

linear in unknowns: w and coefficients of HH is defined up to an arbitrary scale factorhow many points are necessary to solve for H?

[Source: N. Snavely]

Raquel Urtasun (TTI-C) Computer Vision Jan 24, 2013 23 / 44

Page 50: Computer Vision: Image Alignmenturtasun/courses/CV/lecture06.pdf · Readings Chapter 2.1, 3.6, 4.3 and 6.1 of Szeliski’s book Chapter 1 of Forsyth & Ponce Raquel Urtasun (TTI-C)

Homographies

!"!#"

To unwarp (rectify) and image

solve for homography H given p and p′

solve equations of the form: wp′ = Hp

linear in unknowns: w and coefficients of H

H is defined up to an arbitrary scale factorhow many points are necessary to solve for H?

[Source: N. Snavely]

Raquel Urtasun (TTI-C) Computer Vision Jan 24, 2013 23 / 44

Page 51: Computer Vision: Image Alignmenturtasun/courses/CV/lecture06.pdf · Readings Chapter 2.1, 3.6, 4.3 and 6.1 of Szeliski’s book Chapter 1 of Forsyth & Ponce Raquel Urtasun (TTI-C)

Homographies

!"!#"

To unwarp (rectify) and image

solve for homography H given p and p′

solve equations of the form: wp′ = Hp

linear in unknowns: w and coefficients of HH is defined up to an arbitrary scale factor

how many points are necessary to solve for H?

[Source: N. Snavely]

Raquel Urtasun (TTI-C) Computer Vision Jan 24, 2013 23 / 44

Page 52: Computer Vision: Image Alignmenturtasun/courses/CV/lecture06.pdf · Readings Chapter 2.1, 3.6, 4.3 and 6.1 of Szeliski’s book Chapter 1 of Forsyth & Ponce Raquel Urtasun (TTI-C)

Homographies

!"!#"

To unwarp (rectify) and image

solve for homography H given p and p′

solve equations of the form: wp′ = Hp

linear in unknowns: w and coefficients of HH is defined up to an arbitrary scale factorhow many points are necessary to solve for H?

[Source: N. Snavely]

Raquel Urtasun (TTI-C) Computer Vision Jan 24, 2013 23 / 44

Page 53: Computer Vision: Image Alignmenturtasun/courses/CV/lecture06.pdf · Readings Chapter 2.1, 3.6, 4.3 and 6.1 of Szeliski’s book Chapter 1 of Forsyth & Ponce Raquel Urtasun (TTI-C)

Homographies

!"!#"

To unwarp (rectify) and image

solve for homography H given p and p′

solve equations of the form: wp′ = Hp

linear in unknowns: w and coefficients of HH is defined up to an arbitrary scale factorhow many points are necessary to solve for H?

[Source: N. Snavely]

Raquel Urtasun (TTI-C) Computer Vision Jan 24, 2013 23 / 44

Page 54: Computer Vision: Image Alignmenturtasun/courses/CV/lecture06.pdf · Readings Chapter 2.1, 3.6, 4.3 and 6.1 of Szeliski’s book Chapter 1 of Forsyth & Ponce Raquel Urtasun (TTI-C)

Solving for Homographies

ax ′iay ′ia

=

h00 h01 h02h10 h11 h12h20 h21 h22

xiyi1

To get to non-homogenous coordinates

x ′i =h00xi + h01yi + h02h20xi + h21yi + h22

y ′i =h10xi + h11yi + h12h20xi + h21yi + h22

Warning: This is non-linear!!!

But wait a minute!

x ′i (h20xi + h21yi + h22) = h00xi + h01yi + h02

y ′i (h20xi + h21yi + h22) = h10xi + h11yi + h12

Raquel Urtasun (TTI-C) Computer Vision Jan 24, 2013 24 / 44

Page 55: Computer Vision: Image Alignmenturtasun/courses/CV/lecture06.pdf · Readings Chapter 2.1, 3.6, 4.3 and 6.1 of Szeliski’s book Chapter 1 of Forsyth & Ponce Raquel Urtasun (TTI-C)

Solving for Homographies

ax ′iay ′ia

=

h00 h01 h02h10 h11 h12h20 h21 h22

xiyi1

To get to non-homogenous coordinates

x ′i =h00xi + h01yi + h02h20xi + h21yi + h22

y ′i =h10xi + h11yi + h12h20xi + h21yi + h22

Warning: This is non-linear!!!

But wait a minute!

x ′i (h20xi + h21yi + h22) = h00xi + h01yi + h02

y ′i (h20xi + h21yi + h22) = h10xi + h11yi + h12

Raquel Urtasun (TTI-C) Computer Vision Jan 24, 2013 24 / 44

Page 56: Computer Vision: Image Alignmenturtasun/courses/CV/lecture06.pdf · Readings Chapter 2.1, 3.6, 4.3 and 6.1 of Szeliski’s book Chapter 1 of Forsyth & Ponce Raquel Urtasun (TTI-C)

Solving for Homographies

ax ′iay ′ia

=

h00 h01 h02h10 h11 h12h20 h21 h22

xiyi1

To get to non-homogenous coordinates

x ′i =h00xi + h01yi + h02h20xi + h21yi + h22

y ′i =h10xi + h11yi + h12h20xi + h21yi + h22

Warning: This is non-linear!!!

But wait a minute!

x ′i (h20xi + h21yi + h22) = h00xi + h01yi + h02

y ′i (h20xi + h21yi + h22) = h10xi + h11yi + h12

Raquel Urtasun (TTI-C) Computer Vision Jan 24, 2013 24 / 44

Page 57: Computer Vision: Image Alignmenturtasun/courses/CV/lecture06.pdf · Readings Chapter 2.1, 3.6, 4.3 and 6.1 of Szeliski’s book Chapter 1 of Forsyth & Ponce Raquel Urtasun (TTI-C)

Solving for Homographies

ax ′iay ′ia

=

h00 h01 h02h10 h11 h12h20 h21 h22

xiyi1

To get to non-homogenous coordinates

x ′i =h00xi + h01yi + h02h20xi + h21yi + h22

y ′i =h10xi + h11yi + h12h20xi + h21yi + h22

Warning: This is non-linear!!!

But wait a minute!

x ′i (h20xi + h21yi + h22) = h00xi + h01yi + h02

y ′i (h20xi + h21yi + h22) = h10xi + h11yi + h12

Raquel Urtasun (TTI-C) Computer Vision Jan 24, 2013 24 / 44

Page 58: Computer Vision: Image Alignmenturtasun/courses/CV/lecture06.pdf · Readings Chapter 2.1, 3.6, 4.3 and 6.1 of Szeliski’s book Chapter 1 of Forsyth & Ponce Raquel Urtasun (TTI-C)

Solving for homographies

x ′i (h20xi + h21yi + h22) = h00xi + h01yi + h02

y ′i (h20xi + h21yi + h22) = h10xi + h11yi + h12

This is still linear in the unknowns

Raquel Urtasun (TTI-C) Computer Vision Jan 24, 2013 25 / 44

Page 59: Computer Vision: Image Alignmenturtasun/courses/CV/lecture06.pdf · Readings Chapter 2.1, 3.6, 4.3 and 6.1 of Szeliski’s book Chapter 1 of Forsyth & Ponce Raquel Urtasun (TTI-C)

Solving for homographies

Taking all the observations into account

!"#$#%# %# !"#

Defines a least squares problem:

minh||Ah||22

Since h is only defined up to scale, solve for unit vector

Solution: h = eigenvector of ATA with smallest eigenvalue

Works with 4 or more points

Raquel Urtasun (TTI-C) Computer Vision Jan 24, 2013 26 / 44

Page 60: Computer Vision: Image Alignmenturtasun/courses/CV/lecture06.pdf · Readings Chapter 2.1, 3.6, 4.3 and 6.1 of Szeliski’s book Chapter 1 of Forsyth & Ponce Raquel Urtasun (TTI-C)

Solving for homographies

Taking all the observations into account

!"#$#%# %# !"#

Defines a least squares problem:

minh||Ah||22

Since h is only defined up to scale, solve for unit vector

Solution: h = eigenvector of ATA with smallest eigenvalue

Works with 4 or more points

Raquel Urtasun (TTI-C) Computer Vision Jan 24, 2013 26 / 44

Page 61: Computer Vision: Image Alignmenturtasun/courses/CV/lecture06.pdf · Readings Chapter 2.1, 3.6, 4.3 and 6.1 of Szeliski’s book Chapter 1 of Forsyth & Ponce Raquel Urtasun (TTI-C)

Solving for homographies

Taking all the observations into account

!"#$#%# %# !"#

Defines a least squares problem:

minh||Ah||22

Since h is only defined up to scale, solve for unit vector

Solution: h = eigenvector of ATA with smallest eigenvalue

Works with 4 or more points

Raquel Urtasun (TTI-C) Computer Vision Jan 24, 2013 26 / 44

Page 62: Computer Vision: Image Alignmenturtasun/courses/CV/lecture06.pdf · Readings Chapter 2.1, 3.6, 4.3 and 6.1 of Szeliski’s book Chapter 1 of Forsyth & Ponce Raquel Urtasun (TTI-C)

Solving for homographies

Taking all the observations into account

!"#$#%# %# !"#

Defines a least squares problem:

minh||Ah||22

Since h is only defined up to scale, solve for unit vector

Solution: h = eigenvector of ATA with smallest eigenvalue

Works with 4 or more points

Raquel Urtasun (TTI-C) Computer Vision Jan 24, 2013 26 / 44

Page 63: Computer Vision: Image Alignmenturtasun/courses/CV/lecture06.pdf · Readings Chapter 2.1, 3.6, 4.3 and 6.1 of Szeliski’s book Chapter 1 of Forsyth & Ponce Raquel Urtasun (TTI-C)

Solving for homographies

Taking all the observations into account

!"#$#%# %# !"#

Defines a least squares problem:

minh||Ah||22

Since h is only defined up to scale, solve for unit vector

Solution: h = eigenvector of ATA with smallest eigenvalue

Works with 4 or more points

Raquel Urtasun (TTI-C) Computer Vision Jan 24, 2013 26 / 44

Page 64: Computer Vision: Image Alignmenturtasun/courses/CV/lecture06.pdf · Readings Chapter 2.1, 3.6, 4.3 and 6.1 of Szeliski’s book Chapter 1 of Forsyth & Ponce Raquel Urtasun (TTI-C)

Image Alignment Algorithm

Given images A and B

1 Compute image features for A and B

2 Match features between A and B

3 Compute homography between A and B using least squares on set ofmatches

Is there a problem with this?

[Source: N. Snavely]

Raquel Urtasun (TTI-C) Computer Vision Jan 24, 2013 27 / 44

Page 65: Computer Vision: Image Alignmenturtasun/courses/CV/lecture06.pdf · Readings Chapter 2.1, 3.6, 4.3 and 6.1 of Szeliski’s book Chapter 1 of Forsyth & Ponce Raquel Urtasun (TTI-C)

Image Alignment Algorithm

Given images A and B

1 Compute image features for A and B

2 Match features between A and B

3 Compute homography between A and B using least squares on set ofmatches

Is there a problem with this?

[Source: N. Snavely]

Raquel Urtasun (TTI-C) Computer Vision Jan 24, 2013 27 / 44

Page 66: Computer Vision: Image Alignmenturtasun/courses/CV/lecture06.pdf · Readings Chapter 2.1, 3.6, 4.3 and 6.1 of Szeliski’s book Chapter 1 of Forsyth & Ponce Raquel Urtasun (TTI-C)

Robustness

!"#$%&'()

%*$%&'()

[Source: N. Snavely]

Raquel Urtasun (TTI-C) Computer Vision Jan 24, 2013 28 / 44

Page 67: Computer Vision: Image Alignmenturtasun/courses/CV/lecture06.pdf · Readings Chapter 2.1, 3.6, 4.3 and 6.1 of Szeliski’s book Chapter 1 of Forsyth & Ponce Raquel Urtasun (TTI-C)

Simple case

Lets consider a simpler example ... linear regression

!"#$%&'()*+,)-)%+.&),#),/&0&)1-,-2#+.,0) 3&-0,)045-"&0)6,)

How can we fix this?

We need a better cost function

[Source: N. Snavely]

Raquel Urtasun (TTI-C) Computer Vision Jan 24, 2013 29 / 44

Page 68: Computer Vision: Image Alignmenturtasun/courses/CV/lecture06.pdf · Readings Chapter 2.1, 3.6, 4.3 and 6.1 of Szeliski’s book Chapter 1 of Forsyth & Ponce Raquel Urtasun (TTI-C)

Simple case

Lets consider a simpler example ... linear regression

!"#$%&'()*+,)-)%+.&),#),/&0&)1-,-2#+.,0) 3&-0,)045-"&0)6,)

How can we fix this?

We need a better cost function

[Source: N. Snavely]Raquel Urtasun (TTI-C) Computer Vision Jan 24, 2013 29 / 44

Page 69: Computer Vision: Image Alignmenturtasun/courses/CV/lecture06.pdf · Readings Chapter 2.1, 3.6, 4.3 and 6.1 of Szeliski’s book Chapter 1 of Forsyth & Ponce Raquel Urtasun (TTI-C)

Simple case

Lets consider a simpler example ... linear regression

!"#$%&'()*+,)-)%+.&),#),/&0&)1-,-2#+.,0) 3&-0,)045-"&0)6,)

How can we fix this?

We need a better cost function

[Source: N. Snavely]Raquel Urtasun (TTI-C) Computer Vision Jan 24, 2013 29 / 44

Page 70: Computer Vision: Image Alignmenturtasun/courses/CV/lecture06.pdf · Readings Chapter 2.1, 3.6, 4.3 and 6.1 of Szeliski’s book Chapter 1 of Forsyth & Ponce Raquel Urtasun (TTI-C)

More Robust Least-squares

Least-squares assumes that the noise follows a Gaussian distribution

M-estimators are use to make least-squares more robust

They involve applying a robust penalty function ρ(r) to the residuals

ERLS(∆p) =∑i

ρ(||ri ||)

instead of taking the square of the residual

We can take the derivative with respect to p and set it to 0∑i

ψ(||ri ||)∂||ri ||∂p

=∑i

ψ(||ri ||)||ri ||

rTi∂ri∂p

= 0

where ψ(r) = ρ′(r) is the derivative, called influence function

If we introduce a weight w(r) = ψ(r)/r , we observe that finding thestationary point is equivalent to minimizing the iteratively reweightedleast squares (IRLS)

EIRLS =∑i

w(||ri ||)||ri ||2

Raquel Urtasun (TTI-C) Computer Vision Jan 24, 2013 30 / 44

Page 71: Computer Vision: Image Alignmenturtasun/courses/CV/lecture06.pdf · Readings Chapter 2.1, 3.6, 4.3 and 6.1 of Szeliski’s book Chapter 1 of Forsyth & Ponce Raquel Urtasun (TTI-C)

More Robust Least-squares

Least-squares assumes that the noise follows a Gaussian distribution

M-estimators are use to make least-squares more robust

They involve applying a robust penalty function ρ(r) to the residuals

ERLS(∆p) =∑i

ρ(||ri ||)

instead of taking the square of the residual

We can take the derivative with respect to p and set it to 0∑i

ψ(||ri ||)∂||ri ||∂p

=∑i

ψ(||ri ||)||ri ||

rTi∂ri∂p

= 0

where ψ(r) = ρ′(r) is the derivative, called influence function

If we introduce a weight w(r) = ψ(r)/r , we observe that finding thestationary point is equivalent to minimizing the iteratively reweightedleast squares (IRLS)

EIRLS =∑i

w(||ri ||)||ri ||2

Raquel Urtasun (TTI-C) Computer Vision Jan 24, 2013 30 / 44

Page 72: Computer Vision: Image Alignmenturtasun/courses/CV/lecture06.pdf · Readings Chapter 2.1, 3.6, 4.3 and 6.1 of Szeliski’s book Chapter 1 of Forsyth & Ponce Raquel Urtasun (TTI-C)

More Robust Least-squares

Least-squares assumes that the noise follows a Gaussian distribution

M-estimators are use to make least-squares more robust

They involve applying a robust penalty function ρ(r) to the residuals

ERLS(∆p) =∑i

ρ(||ri ||)

instead of taking the square of the residual

We can take the derivative with respect to p and set it to 0∑i

ψ(||ri ||)∂||ri ||∂p

=∑i

ψ(||ri ||)||ri ||

rTi∂ri∂p

= 0

where ψ(r) = ρ′(r) is the derivative, called influence function

If we introduce a weight w(r) = ψ(r)/r , we observe that finding thestationary point is equivalent to minimizing the iteratively reweightedleast squares (IRLS)

EIRLS =∑i

w(||ri ||)||ri ||2

Raquel Urtasun (TTI-C) Computer Vision Jan 24, 2013 30 / 44

Page 73: Computer Vision: Image Alignmenturtasun/courses/CV/lecture06.pdf · Readings Chapter 2.1, 3.6, 4.3 and 6.1 of Szeliski’s book Chapter 1 of Forsyth & Ponce Raquel Urtasun (TTI-C)

More Robust Least-squares

Least-squares assumes that the noise follows a Gaussian distribution

M-estimators are use to make least-squares more robust

They involve applying a robust penalty function ρ(r) to the residuals

ERLS(∆p) =∑i

ρ(||ri ||)

instead of taking the square of the residual

We can take the derivative with respect to p and set it to 0∑i

ψ(||ri ||)∂||ri ||∂p

=∑i

ψ(||ri ||)||ri ||

rTi∂ri∂p

= 0

where ψ(r) = ρ′(r) is the derivative, called influence function

If we introduce a weight w(r) = ψ(r)/r , we observe that finding thestationary point is equivalent to minimizing the iteratively reweightedleast squares (IRLS)

EIRLS =∑i

w(||ri ||)||ri ||2

Raquel Urtasun (TTI-C) Computer Vision Jan 24, 2013 30 / 44

Page 74: Computer Vision: Image Alignmenturtasun/courses/CV/lecture06.pdf · Readings Chapter 2.1, 3.6, 4.3 and 6.1 of Szeliski’s book Chapter 1 of Forsyth & Ponce Raquel Urtasun (TTI-C)

More Robust Least-squares

Least-squares assumes that the noise follows a Gaussian distribution

M-estimators are use to make least-squares more robust

They involve applying a robust penalty function ρ(r) to the residuals

ERLS(∆p) =∑i

ρ(||ri ||)

instead of taking the square of the residual

We can take the derivative with respect to p and set it to 0∑i

ψ(||ri ||)∂||ri ||∂p

=∑i

ψ(||ri ||)||ri ||

rTi∂ri∂p

= 0

where ψ(r) = ρ′(r) is the derivative, called influence function

If we introduce a weight w(r) = ψ(r)/r , we observe that finding thestationary point is equivalent to minimizing the iteratively reweightedleast squares (IRLS)

EIRLS =∑i

w(||ri ||)||ri ||2

Raquel Urtasun (TTI-C) Computer Vision Jan 24, 2013 30 / 44

Page 75: Computer Vision: Image Alignmenturtasun/courses/CV/lecture06.pdf · Readings Chapter 2.1, 3.6, 4.3 and 6.1 of Szeliski’s book Chapter 1 of Forsyth & Ponce Raquel Urtasun (TTI-C)

Iterative reweighted least-squares

We want to minimize

EIRLS =∑i

w(||ri ||)||ri ||2

A simple algorithm works by iterating between

1 Solving for the parameters p2 Solving for the weights w

When the number of outliers is very high, IRLS does not work well (will notconverge to the global optima)

Raquel Urtasun (TTI-C) Computer Vision Jan 24, 2013 31 / 44

Page 76: Computer Vision: Image Alignmenturtasun/courses/CV/lecture06.pdf · Readings Chapter 2.1, 3.6, 4.3 and 6.1 of Szeliski’s book Chapter 1 of Forsyth & Ponce Raquel Urtasun (TTI-C)

Iterative reweighted least-squares

We want to minimize

EIRLS =∑i

w(||ri ||)||ri ||2

A simple algorithm works by iterating between

1 Solving for the parameters p2 Solving for the weights w

When the number of outliers is very high, IRLS does not work well (will notconverge to the global optima)

Raquel Urtasun (TTI-C) Computer Vision Jan 24, 2013 31 / 44

Page 77: Computer Vision: Image Alignmenturtasun/courses/CV/lecture06.pdf · Readings Chapter 2.1, 3.6, 4.3 and 6.1 of Szeliski’s book Chapter 1 of Forsyth & Ponce Raquel Urtasun (TTI-C)

Iterative reweighted least-squares

We want to minimize

EIRLS =∑i

w(||ri ||)||ri ||2

A simple algorithm works by iterating between

1 Solving for the parameters p2 Solving for the weights w

When the number of outliers is very high, IRLS does not work well (will notconverge to the global optima)

Raquel Urtasun (TTI-C) Computer Vision Jan 24, 2013 31 / 44

Page 78: Computer Vision: Image Alignmenturtasun/courses/CV/lecture06.pdf · Readings Chapter 2.1, 3.6, 4.3 and 6.1 of Szeliski’s book Chapter 1 of Forsyth & Ponce Raquel Urtasun (TTI-C)

Simple Idea

Given a hypothesized line, count the number of points that agree with theline

Agree = within a small distance of the line i.e., the inliers to that line

For all possible lines, select the one with the largest number of inliers

[Source: N. Snavely]

Raquel Urtasun (TTI-C) Computer Vision Jan 24, 2013 32 / 44

Page 79: Computer Vision: Image Alignmenturtasun/courses/CV/lecture06.pdf · Readings Chapter 2.1, 3.6, 4.3 and 6.1 of Szeliski’s book Chapter 1 of Forsyth & Ponce Raquel Urtasun (TTI-C)

Simple Idea

Given a hypothesized line, count the number of points that agree with theline

Agree = within a small distance of the line i.e., the inliers to that line

For all possible lines, select the one with the largest number of inliers

[Source: N. Snavely]

Raquel Urtasun (TTI-C) Computer Vision Jan 24, 2013 32 / 44

Page 80: Computer Vision: Image Alignmenturtasun/courses/CV/lecture06.pdf · Readings Chapter 2.1, 3.6, 4.3 and 6.1 of Szeliski’s book Chapter 1 of Forsyth & Ponce Raquel Urtasun (TTI-C)

Simple Idea

Given a hypothesized line, count the number of points that agree with theline

Agree = within a small distance of the line i.e., the inliers to that line

For all possible lines, select the one with the largest number of inliers

[Source: N. Snavely]

Raquel Urtasun (TTI-C) Computer Vision Jan 24, 2013 32 / 44

Page 81: Computer Vision: Image Alignmenturtasun/courses/CV/lecture06.pdf · Readings Chapter 2.1, 3.6, 4.3 and 6.1 of Szeliski’s book Chapter 1 of Forsyth & Ponce Raquel Urtasun (TTI-C)

Counting Inliers

!"#$%&'()*)

[Source: N. Snavely]

Raquel Urtasun (TTI-C) Computer Vision Jan 24, 2013 33 / 44

Page 82: Computer Vision: Image Alignmenturtasun/courses/CV/lecture06.pdf · Readings Chapter 2.1, 3.6, 4.3 and 6.1 of Szeliski’s book Chapter 1 of Forsyth & Ponce Raquel Urtasun (TTI-C)

Counting Inliers

!"#$%&'()*+)

[Source: N. Snavely]

Raquel Urtasun (TTI-C) Computer Vision Jan 24, 2013 33 / 44

Page 83: Computer Vision: Image Alignmenturtasun/courses/CV/lecture06.pdf · Readings Chapter 2.1, 3.6, 4.3 and 6.1 of Szeliski’s book Chapter 1 of Forsyth & Ponce Raquel Urtasun (TTI-C)

Counting Inliers

!"#$%&'()*+)

What’s the problem with this approach?

Raquel Urtasun (TTI-C) Computer Vision Jan 24, 2013 33 / 44

Page 84: Computer Vision: Image Alignmenturtasun/courses/CV/lecture06.pdf · Readings Chapter 2.1, 3.6, 4.3 and 6.1 of Szeliski’s book Chapter 1 of Forsyth & Ponce Raquel Urtasun (TTI-C)

How do we find the best line?

Unlike least-squares, no simple closed-form solution

Hypothesize-and-test

Try out many lines, keep the best one

Which lines?

Raquel Urtasun (TTI-C) Computer Vision Jan 24, 2013 34 / 44

Page 85: Computer Vision: Image Alignmenturtasun/courses/CV/lecture06.pdf · Readings Chapter 2.1, 3.6, 4.3 and 6.1 of Szeliski’s book Chapter 1 of Forsyth & Ponce Raquel Urtasun (TTI-C)

How do we find the best line?

Unlike least-squares, no simple closed-form solution

Hypothesize-and-test

Try out many lines, keep the best one

Which lines?

Raquel Urtasun (TTI-C) Computer Vision Jan 24, 2013 34 / 44

Page 86: Computer Vision: Image Alignmenturtasun/courses/CV/lecture06.pdf · Readings Chapter 2.1, 3.6, 4.3 and 6.1 of Szeliski’s book Chapter 1 of Forsyth & Ponce Raquel Urtasun (TTI-C)

How do we find the best line?

Unlike least-squares, no simple closed-form solution

Hypothesize-and-test

Try out many lines, keep the best one

Which lines?

Raquel Urtasun (TTI-C) Computer Vision Jan 24, 2013 34 / 44

Page 87: Computer Vision: Image Alignmenturtasun/courses/CV/lecture06.pdf · Readings Chapter 2.1, 3.6, 4.3 and 6.1 of Szeliski’s book Chapter 1 of Forsyth & Ponce Raquel Urtasun (TTI-C)

How do we find the best line?

Unlike least-squares, no simple closed-form solution

Hypothesize-and-test

Try out many lines, keep the best one

Which lines?

Raquel Urtasun (TTI-C) Computer Vision Jan 24, 2013 34 / 44

Page 88: Computer Vision: Image Alignmenturtasun/courses/CV/lecture06.pdf · Readings Chapter 2.1, 3.6, 4.3 and 6.1 of Szeliski’s book Chapter 1 of Forsyth & Ponce Raquel Urtasun (TTI-C)

Translations

[Source: N. Snavely]

Raquel Urtasun (TTI-C) Computer Vision Jan 24, 2013 35 / 44

Page 89: Computer Vision: Image Alignmenturtasun/courses/CV/lecture06.pdf · Readings Chapter 2.1, 3.6, 4.3 and 6.1 of Szeliski’s book Chapter 1 of Forsyth & Ponce Raquel Urtasun (TTI-C)

RAndom SAmple Consensus

!"#"$%&!"#&'(%$)&(%&*(+,-'.&$-/+%&$"%$#&'&

[Source: N. Snavely]

Raquel Urtasun (TTI-C) Computer Vision Jan 24, 2013 36 / 44

Page 90: Computer Vision: Image Alignmenturtasun/courses/CV/lecture06.pdf · Readings Chapter 2.1, 3.6, 4.3 and 6.1 of Szeliski’s book Chapter 1 of Forsyth & Ponce Raquel Urtasun (TTI-C)

RAndom SAmple Consensus

!"#"$%&'()%*"+&,'%$*&'%&+'(-),.&$)/(%&!"#!$%&&

[Source: N. Snavely]

Raquel Urtasun (TTI-C) Computer Vision Jan 24, 2013 36 / 44

Page 91: Computer Vision: Image Alignmenturtasun/courses/CV/lecture06.pdf · Readings Chapter 2.1, 3.6, 4.3 and 6.1 of Szeliski’s book Chapter 1 of Forsyth & Ponce Raquel Urtasun (TTI-C)

RAndom SAmple Consensus

!"#$"#%#&'%#()*+,)-.*%/0#&%#&'%&01&'+#%*"23'(%.4%0*,0'(+%

[Source: N. Snavely]

Raquel Urtasun (TTI-C) Computer Vision Jan 24, 2013 36 / 44

Page 92: Computer Vision: Image Alignmenturtasun/courses/CV/lecture06.pdf · Readings Chapter 2.1, 3.6, 4.3 and 6.1 of Szeliski’s book Chapter 1 of Forsyth & Ponce Raquel Urtasun (TTI-C)

RANSAC

All the inliers will agree with each other on the translation vector; the(hopefully small) number of outliers will (hopefully) disagree with each other

RANSAC only has guarantees if there are < 50% outliers

”All good matches are alike; every bad match is bad in its own way.” –[Tolstoy via Alyosha Efros]

[Source: N. Snavely]

Raquel Urtasun (TTI-C) Computer Vision Jan 24, 2013 37 / 44

Page 93: Computer Vision: Image Alignmenturtasun/courses/CV/lecture06.pdf · Readings Chapter 2.1, 3.6, 4.3 and 6.1 of Szeliski’s book Chapter 1 of Forsyth & Ponce Raquel Urtasun (TTI-C)

RANSAC

All the inliers will agree with each other on the translation vector; the(hopefully small) number of outliers will (hopefully) disagree with each other

RANSAC only has guarantees if there are < 50% outliers

”All good matches are alike; every bad match is bad in its own way.” –[Tolstoy via Alyosha Efros]

[Source: N. Snavely]

Raquel Urtasun (TTI-C) Computer Vision Jan 24, 2013 37 / 44

Page 94: Computer Vision: Image Alignmenturtasun/courses/CV/lecture06.pdf · Readings Chapter 2.1, 3.6, 4.3 and 6.1 of Szeliski’s book Chapter 1 of Forsyth & Ponce Raquel Urtasun (TTI-C)

RANSAC

All the inliers will agree with each other on the translation vector; the(hopefully small) number of outliers will (hopefully) disagree with each other

RANSAC only has guarantees if there are < 50% outliers

”All good matches are alike; every bad match is bad in its own way.” –[Tolstoy via Alyosha Efros]

[Source: N. Snavely]

Raquel Urtasun (TTI-C) Computer Vision Jan 24, 2013 37 / 44

Page 95: Computer Vision: Image Alignmenturtasun/courses/CV/lecture06.pdf · Readings Chapter 2.1, 3.6, 4.3 and 6.1 of Szeliski’s book Chapter 1 of Forsyth & Ponce Raquel Urtasun (TTI-C)

RANSAC for line fitting example

1 Randomly select minimalsubset of points

2 Hypothesize a model

3 Compute error function

4 Select points consistentwith model

5 Repeat hypothesize andverify loop

6 Choose model withlargest set of inliers

[Source: R. Raguram]

Raquel Urtasun (TTI-C) Computer Vision Jan 24, 2013 38 / 44

Page 96: Computer Vision: Image Alignmenturtasun/courses/CV/lecture06.pdf · Readings Chapter 2.1, 3.6, 4.3 and 6.1 of Szeliski’s book Chapter 1 of Forsyth & Ponce Raquel Urtasun (TTI-C)

RANSAC for line fitting example

1 Randomly select minimalsubset of points

2 Hypothesize a model

3 Compute error function

4 Select points consistentwith model

5 Repeat hypothesize andverify loop

6 Choose model withlargest set of inliers

[Source: R. Raguram]

Raquel Urtasun (TTI-C) Computer Vision Jan 24, 2013 38 / 44

Page 97: Computer Vision: Image Alignmenturtasun/courses/CV/lecture06.pdf · Readings Chapter 2.1, 3.6, 4.3 and 6.1 of Szeliski’s book Chapter 1 of Forsyth & Ponce Raquel Urtasun (TTI-C)

RANSAC for line fitting example

1 Randomly select minimalsubset of points

2 Hypothesize a model

3 Compute error function

4 Select points consistentwith model

5 Repeat hypothesize andverify loop

6 Choose model withlargest set of inliers

[Source: R. Raguram]

Raquel Urtasun (TTI-C) Computer Vision Jan 24, 2013 38 / 44

Page 98: Computer Vision: Image Alignmenturtasun/courses/CV/lecture06.pdf · Readings Chapter 2.1, 3.6, 4.3 and 6.1 of Szeliski’s book Chapter 1 of Forsyth & Ponce Raquel Urtasun (TTI-C)

RANSAC for line fitting example

1 Randomly select minimalsubset of points

2 Hypothesize a model

3 Compute error function

4 Select points consistentwith model

5 Repeat hypothesize andverify loop

6 Choose model withlargest set of inliers

[Source: R. Raguram]

Raquel Urtasun (TTI-C) Computer Vision Jan 24, 2013 38 / 44

Page 99: Computer Vision: Image Alignmenturtasun/courses/CV/lecture06.pdf · Readings Chapter 2.1, 3.6, 4.3 and 6.1 of Szeliski’s book Chapter 1 of Forsyth & Ponce Raquel Urtasun (TTI-C)

RANSAC for line fitting example

1 Randomly select minimalsubset of points

2 Hypothesize a model

3 Compute error function

4 Select points consistentwith model

5 Repeat hypothesize andverify loop

6 Choose model withlargest set of inliers

[Source: R. Raguram]

Raquel Urtasun (TTI-C) Computer Vision Jan 24, 2013 38 / 44

Page 100: Computer Vision: Image Alignmenturtasun/courses/CV/lecture06.pdf · Readings Chapter 2.1, 3.6, 4.3 and 6.1 of Szeliski’s book Chapter 1 of Forsyth & Ponce Raquel Urtasun (TTI-C)

RANSAC for line fitting example

1 Randomly select minimalsubset of points

2 Hypothesize a model

3 Compute error function

4 Select points consistentwith model

5 Repeat hypothesize andverify loop

6 Choose model withlargest set of inliers

[Source: R. Raguram]

Raquel Urtasun (TTI-C) Computer Vision Jan 24, 2013 38 / 44

Page 101: Computer Vision: Image Alignmenturtasun/courses/CV/lecture06.pdf · Readings Chapter 2.1, 3.6, 4.3 and 6.1 of Szeliski’s book Chapter 1 of Forsyth & Ponce Raquel Urtasun (TTI-C)

RANSAC for line fitting example

1 Randomly select minimalsubset of points

2 Hypothesize a model

3 Compute error function

4 Select points consistentwith model

5 Repeat hypothesize andverify loop

6 Choose model withlargest set of inliers

[Source: R. Raguram]

Raquel Urtasun (TTI-C) Computer Vision Jan 24, 2013 38 / 44

Page 102: Computer Vision: Image Alignmenturtasun/courses/CV/lecture06.pdf · Readings Chapter 2.1, 3.6, 4.3 and 6.1 of Szeliski’s book Chapter 1 of Forsyth & Ponce Raquel Urtasun (TTI-C)

RANSAC

Inlier threshold related to the amount of noise we expect in inliers

Often model noise as Gaussian with some standard deviation (e.g., 3 pixels)

Number of rounds related to the percentage of outliers we expect, and theprobability of success we’d like to guarantee

Suppose there are 20% outliers, and we want to find the correct answer with99% probability

How many rounds do we need?

Raquel Urtasun (TTI-C) Computer Vision Jan 24, 2013 39 / 44

Page 103: Computer Vision: Image Alignmenturtasun/courses/CV/lecture06.pdf · Readings Chapter 2.1, 3.6, 4.3 and 6.1 of Szeliski’s book Chapter 1 of Forsyth & Ponce Raquel Urtasun (TTI-C)

RANSAC

Inlier threshold related to the amount of noise we expect in inliers

Often model noise as Gaussian with some standard deviation (e.g., 3 pixels)

Number of rounds related to the percentage of outliers we expect, and theprobability of success we’d like to guarantee

Suppose there are 20% outliers, and we want to find the correct answer with99% probability

How many rounds do we need?

Raquel Urtasun (TTI-C) Computer Vision Jan 24, 2013 39 / 44

Page 104: Computer Vision: Image Alignmenturtasun/courses/CV/lecture06.pdf · Readings Chapter 2.1, 3.6, 4.3 and 6.1 of Szeliski’s book Chapter 1 of Forsyth & Ponce Raquel Urtasun (TTI-C)

RANSAC

Inlier threshold related to the amount of noise we expect in inliers

Often model noise as Gaussian with some standard deviation (e.g., 3 pixels)

Number of rounds related to the percentage of outliers we expect, and theprobability of success we’d like to guarantee

Suppose there are 20% outliers, and we want to find the correct answer with99% probability

How many rounds do we need?

Raquel Urtasun (TTI-C) Computer Vision Jan 24, 2013 39 / 44

Page 105: Computer Vision: Image Alignmenturtasun/courses/CV/lecture06.pdf · Readings Chapter 2.1, 3.6, 4.3 and 6.1 of Szeliski’s book Chapter 1 of Forsyth & Ponce Raquel Urtasun (TTI-C)

RANSAC

Inlier threshold related to the amount of noise we expect in inliers

Often model noise as Gaussian with some standard deviation (e.g., 3 pixels)

Number of rounds related to the percentage of outliers we expect, and theprobability of success we’d like to guarantee

Suppose there are 20% outliers, and we want to find the correct answer with99% probability

How many rounds do we need?

Raquel Urtasun (TTI-C) Computer Vision Jan 24, 2013 39 / 44

Page 106: Computer Vision: Image Alignmenturtasun/courses/CV/lecture06.pdf · Readings Chapter 2.1, 3.6, 4.3 and 6.1 of Szeliski’s book Chapter 1 of Forsyth & Ponce Raquel Urtasun (TTI-C)

RANSAC

Inlier threshold related to the amount of noise we expect in inliers

Often model noise as Gaussian with some standard deviation (e.g., 3 pixels)

Number of rounds related to the percentage of outliers we expect, and theprobability of success we’d like to guarantee

Suppose there are 20% outliers, and we want to find the correct answer with99% probability

How many rounds do we need?

Raquel Urtasun (TTI-C) Computer Vision Jan 24, 2013 39 / 44

Page 107: Computer Vision: Image Alignmenturtasun/courses/CV/lecture06.pdf · Readings Chapter 2.1, 3.6, 4.3 and 6.1 of Szeliski’s book Chapter 1 of Forsyth & Ponce Raquel Urtasun (TTI-C)

How many rounds?

Sufficient number of trials S must be tried.

Let p be the probability that any given correspondence is valid and P be thetotal probability of success after S trials.

The likelihood in one trial that all k random samples are inliers is pk

The likelihood that S such trials will all fail is

1− P = (1− pk)S

The required minimum number of trials is

S =log(1− P)

log(1− pk)

The number of trials grows quickly with the number of sample points used.

Use the minimum number of sample points k possible for any given trial

Raquel Urtasun (TTI-C) Computer Vision Jan 24, 2013 40 / 44

Page 108: Computer Vision: Image Alignmenturtasun/courses/CV/lecture06.pdf · Readings Chapter 2.1, 3.6, 4.3 and 6.1 of Szeliski’s book Chapter 1 of Forsyth & Ponce Raquel Urtasun (TTI-C)

How many rounds?

Sufficient number of trials S must be tried.

Let p be the probability that any given correspondence is valid and P be thetotal probability of success after S trials.

The likelihood in one trial that all k random samples are inliers is pk

The likelihood that S such trials will all fail is

1− P = (1− pk)S

The required minimum number of trials is

S =log(1− P)

log(1− pk)

The number of trials grows quickly with the number of sample points used.

Use the minimum number of sample points k possible for any given trial

Raquel Urtasun (TTI-C) Computer Vision Jan 24, 2013 40 / 44

Page 109: Computer Vision: Image Alignmenturtasun/courses/CV/lecture06.pdf · Readings Chapter 2.1, 3.6, 4.3 and 6.1 of Szeliski’s book Chapter 1 of Forsyth & Ponce Raquel Urtasun (TTI-C)

How many rounds?

Sufficient number of trials S must be tried.

Let p be the probability that any given correspondence is valid and P be thetotal probability of success after S trials.

The likelihood in one trial that all k random samples are inliers is pk

The likelihood that S such trials will all fail is

1− P = (1− pk)S

The required minimum number of trials is

S =log(1− P)

log(1− pk)

The number of trials grows quickly with the number of sample points used.

Use the minimum number of sample points k possible for any given trial

Raquel Urtasun (TTI-C) Computer Vision Jan 24, 2013 40 / 44

Page 110: Computer Vision: Image Alignmenturtasun/courses/CV/lecture06.pdf · Readings Chapter 2.1, 3.6, 4.3 and 6.1 of Szeliski’s book Chapter 1 of Forsyth & Ponce Raquel Urtasun (TTI-C)

How many rounds?

Sufficient number of trials S must be tried.

Let p be the probability that any given correspondence is valid and P be thetotal probability of success after S trials.

The likelihood in one trial that all k random samples are inliers is pk

The likelihood that S such trials will all fail is

1− P = (1− pk)S

The required minimum number of trials is

S =log(1− P)

log(1− pk)

The number of trials grows quickly with the number of sample points used.

Use the minimum number of sample points k possible for any given trial

Raquel Urtasun (TTI-C) Computer Vision Jan 24, 2013 40 / 44

Page 111: Computer Vision: Image Alignmenturtasun/courses/CV/lecture06.pdf · Readings Chapter 2.1, 3.6, 4.3 and 6.1 of Szeliski’s book Chapter 1 of Forsyth & Ponce Raquel Urtasun (TTI-C)

How many rounds?

Sufficient number of trials S must be tried.

Let p be the probability that any given correspondence is valid and P be thetotal probability of success after S trials.

The likelihood in one trial that all k random samples are inliers is pk

The likelihood that S such trials will all fail is

1− P = (1− pk)S

The required minimum number of trials is

S =log(1− P)

log(1− pk)

The number of trials grows quickly with the number of sample points used.

Use the minimum number of sample points k possible for any given trial

Raquel Urtasun (TTI-C) Computer Vision Jan 24, 2013 40 / 44

Page 112: Computer Vision: Image Alignmenturtasun/courses/CV/lecture06.pdf · Readings Chapter 2.1, 3.6, 4.3 and 6.1 of Szeliski’s book Chapter 1 of Forsyth & Ponce Raquel Urtasun (TTI-C)

How many rounds?

Sufficient number of trials S must be tried.

Let p be the probability that any given correspondence is valid and P be thetotal probability of success after S trials.

The likelihood in one trial that all k random samples are inliers is pk

The likelihood that S such trials will all fail is

1− P = (1− pk)S

The required minimum number of trials is

S =log(1− P)

log(1− pk)

The number of trials grows quickly with the number of sample points used.

Use the minimum number of sample points k possible for any given trial

Raquel Urtasun (TTI-C) Computer Vision Jan 24, 2013 40 / 44

Page 113: Computer Vision: Image Alignmenturtasun/courses/CV/lecture06.pdf · Readings Chapter 2.1, 3.6, 4.3 and 6.1 of Szeliski’s book Chapter 1 of Forsyth & Ponce Raquel Urtasun (TTI-C)

How many rounds?

Sufficient number of trials S must be tried.

Let p be the probability that any given correspondence is valid and P be thetotal probability of success after S trials.

The likelihood in one trial that all k random samples are inliers is pk

The likelihood that S such trials will all fail is

1− P = (1− pk)S

The required minimum number of trials is

S =log(1− P)

log(1− pk)

The number of trials grows quickly with the number of sample points used.

Use the minimum number of sample points k possible for any given trial

Raquel Urtasun (TTI-C) Computer Vision Jan 24, 2013 40 / 44

Page 114: Computer Vision: Image Alignmenturtasun/courses/CV/lecture06.pdf · Readings Chapter 2.1, 3.6, 4.3 and 6.1 of Szeliski’s book Chapter 1 of Forsyth & Ponce Raquel Urtasun (TTI-C)

How big is the number of samples?

For alignment, depends on the motion model

Each sample is a correspondence (pair of matching points)

Raquel Urtasun (TTI-C) Computer Vision Jan 24, 2013 41 / 44

Page 115: Computer Vision: Image Alignmenturtasun/courses/CV/lecture06.pdf · Readings Chapter 2.1, 3.6, 4.3 and 6.1 of Szeliski’s book Chapter 1 of Forsyth & Ponce Raquel Urtasun (TTI-C)

RANSAC pros and cons

Pros

Simple and general

Applicable to many different problems

Often works well in practice

Cons

Parameters to tune

Sometimes too many iterations are required

Can fail for extremely low inlier ratios

We can often do better than brute-force sampling

[Source: N. Snavely]

Raquel Urtasun (TTI-C) Computer Vision Jan 24, 2013 42 / 44

Page 116: Computer Vision: Image Alignmenturtasun/courses/CV/lecture06.pdf · Readings Chapter 2.1, 3.6, 4.3 and 6.1 of Szeliski’s book Chapter 1 of Forsyth & Ponce Raquel Urtasun (TTI-C)

RANSAC pros and cons

Pros

Simple and general

Applicable to many different problems

Often works well in practice

Cons

Parameters to tune

Sometimes too many iterations are required

Can fail for extremely low inlier ratios

We can often do better than brute-force sampling

[Source: N. Snavely]

Raquel Urtasun (TTI-C) Computer Vision Jan 24, 2013 42 / 44

Page 117: Computer Vision: Image Alignmenturtasun/courses/CV/lecture06.pdf · Readings Chapter 2.1, 3.6, 4.3 and 6.1 of Szeliski’s book Chapter 1 of Forsyth & Ponce Raquel Urtasun (TTI-C)

RANSAC pros and cons

Pros

Simple and general

Applicable to many different problems

Often works well in practice

Cons

Parameters to tune

Sometimes too many iterations are required

Can fail for extremely low inlier ratios

We can often do better than brute-force sampling

[Source: N. Snavely]

Raquel Urtasun (TTI-C) Computer Vision Jan 24, 2013 42 / 44

Page 118: Computer Vision: Image Alignmenturtasun/courses/CV/lecture06.pdf · Readings Chapter 2.1, 3.6, 4.3 and 6.1 of Szeliski’s book Chapter 1 of Forsyth & Ponce Raquel Urtasun (TTI-C)

RANSAC pros and cons

Pros

Simple and general

Applicable to many different problems

Often works well in practice

Cons

Parameters to tune

Sometimes too many iterations are required

Can fail for extremely low inlier ratios

We can often do better than brute-force sampling

[Source: N. Snavely]

Raquel Urtasun (TTI-C) Computer Vision Jan 24, 2013 42 / 44

Page 119: Computer Vision: Image Alignmenturtasun/courses/CV/lecture06.pdf · Readings Chapter 2.1, 3.6, 4.3 and 6.1 of Szeliski’s book Chapter 1 of Forsyth & Ponce Raquel Urtasun (TTI-C)

RANSAC pros and cons

Pros

Simple and general

Applicable to many different problems

Often works well in practice

Cons

Parameters to tune

Sometimes too many iterations are required

Can fail for extremely low inlier ratios

We can often do better than brute-force sampling

[Source: N. Snavely]

Raquel Urtasun (TTI-C) Computer Vision Jan 24, 2013 42 / 44

Page 120: Computer Vision: Image Alignmenturtasun/courses/CV/lecture06.pdf · Readings Chapter 2.1, 3.6, 4.3 and 6.1 of Szeliski’s book Chapter 1 of Forsyth & Ponce Raquel Urtasun (TTI-C)

RANSAC pros and cons

Pros

Simple and general

Applicable to many different problems

Often works well in practice

Cons

Parameters to tune

Sometimes too many iterations are required

Can fail for extremely low inlier ratios

We can often do better than brute-force sampling

[Source: N. Snavely]

Raquel Urtasun (TTI-C) Computer Vision Jan 24, 2013 42 / 44

Page 121: Computer Vision: Image Alignmenturtasun/courses/CV/lecture06.pdf · Readings Chapter 2.1, 3.6, 4.3 and 6.1 of Szeliski’s book Chapter 1 of Forsyth & Ponce Raquel Urtasun (TTI-C)

RANSAC pros and cons

Pros

Simple and general

Applicable to many different problems

Often works well in practice

Cons

Parameters to tune

Sometimes too many iterations are required

Can fail for extremely low inlier ratios

We can often do better than brute-force sampling

[Source: N. Snavely]

Raquel Urtasun (TTI-C) Computer Vision Jan 24, 2013 42 / 44

Page 122: Computer Vision: Image Alignmenturtasun/courses/CV/lecture06.pdf · Readings Chapter 2.1, 3.6, 4.3 and 6.1 of Szeliski’s book Chapter 1 of Forsyth & Ponce Raquel Urtasun (TTI-C)

RANSAC as Voting

An example of a ”voting”-based fitting scheme

Each hypothesis gets voted on by each data point, best hypothesis wins

There are many other types of voting schemes, e.g., Hough transforms

[Source: N. Snavely]

Raquel Urtasun (TTI-C) Computer Vision Jan 24, 2013 43 / 44

Page 123: Computer Vision: Image Alignmenturtasun/courses/CV/lecture06.pdf · Readings Chapter 2.1, 3.6, 4.3 and 6.1 of Szeliski’s book Chapter 1 of Forsyth & Ponce Raquel Urtasun (TTI-C)

RANSAC as Voting

An example of a ”voting”-based fitting scheme

Each hypothesis gets voted on by each data point, best hypothesis wins

There are many other types of voting schemes, e.g., Hough transforms

[Source: N. Snavely]

Raquel Urtasun (TTI-C) Computer Vision Jan 24, 2013 43 / 44

Page 124: Computer Vision: Image Alignmenturtasun/courses/CV/lecture06.pdf · Readings Chapter 2.1, 3.6, 4.3 and 6.1 of Szeliski’s book Chapter 1 of Forsyth & Ponce Raquel Urtasun (TTI-C)

RANSAC as Voting

An example of a ”voting”-based fitting scheme

Each hypothesis gets voted on by each data point, best hypothesis wins

There are many other types of voting schemes, e.g., Hough transforms

[Source: N. Snavely]

Raquel Urtasun (TTI-C) Computer Vision Jan 24, 2013 43 / 44

Page 125: Computer Vision: Image Alignmenturtasun/courses/CV/lecture06.pdf · Readings Chapter 2.1, 3.6, 4.3 and 6.1 of Szeliski’s book Chapter 1 of Forsyth & Ponce Raquel Urtasun (TTI-C)

Next class ... more on cameras and projection

Raquel Urtasun (TTI-C) Computer Vision Jan 24, 2013 44 / 44