prof. feng liuweb.cecs.pdx.edu/~fliu/courses/cs410/notes/lecture8.pdfransac the set of putative...

33
Prof. Feng Liu Winter 2020 http://www.cs.pdx.edu/~fliu/courses/cs410/ 01/30/2020

Upload: others

Post on 02-Oct-2020

7 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Prof. Feng Liuweb.cecs.pdx.edu/~fliu/courses/cs410/notes/Lecture8.pdfRANSAC The set of putative matches contains a very high percentage of outliers RANSAC loop: Randomly select a seed

Prof. Feng Liu

Winter 2020

http://www.cs.pdx.edu/~fliu/courses/cs410/

01/30/2020

Page 2: Prof. Feng Liuweb.cecs.pdx.edu/~fliu/courses/cs410/notes/Lecture8.pdfRANSAC The set of putative matches contains a very high percentage of outliers RANSAC loop: Randomly select a seed

Last Time

Hough transform

2

Page 3: Prof. Feng Liuweb.cecs.pdx.edu/~fliu/courses/cs410/notes/Lecture8.pdfRANSAC The set of putative matches contains a very high percentage of outliers RANSAC loop: Randomly select a seed

Today

Image alignment

3The following slides are from Prof. S. Lazebnik

Page 4: Prof. Feng Liuweb.cecs.pdx.edu/~fliu/courses/cs410/notes/Lecture8.pdfRANSAC The set of putative matches contains a very high percentage of outliers RANSAC loop: Randomly select a seed

Image alignment

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

Page 5: Prof. Feng Liuweb.cecs.pdx.edu/~fliu/courses/cs410/notes/Lecture8.pdfRANSAC The set of putative matches contains a very high percentage of outliers RANSAC loop: Randomly select a seed

A look into the past

http://blog.flickr.net/en/2010/01/27/a-look-into-the-past/

Page 6: Prof. Feng Liuweb.cecs.pdx.edu/~fliu/courses/cs410/notes/Lecture8.pdfRANSAC The set of putative matches contains a very high percentage of outliers RANSAC loop: Randomly select a seed

A look into the past

Leningrad during the blockade

http://komen-dant.livejournal.com/345684.html

Page 7: Prof. Feng Liuweb.cecs.pdx.edu/~fliu/courses/cs410/notes/Lecture8.pdfRANSAC The set of putative matches contains a very high percentage of outliers RANSAC loop: Randomly select a seed

Bing streetside images

http://www.bing.com/community/blogs/maps/archive/2010/01/12/new-bing-maps-

application-streetside-photos.aspx

Page 8: Prof. Feng Liuweb.cecs.pdx.edu/~fliu/courses/cs410/notes/Lecture8.pdfRANSAC The set of putative matches contains a very high percentage of outliers RANSAC loop: Randomly select a seed

Image alignment: Applications

Panorama stitching

Recognition

of object

instances

Page 9: Prof. Feng Liuweb.cecs.pdx.edu/~fliu/courses/cs410/notes/Lecture8.pdfRANSAC The set of putative matches contains a very high percentage of outliers RANSAC loop: Randomly select a seed

Image alignment: Applications

Small degree of overlap, intensity changes

Occlusion,

clutter

Page 10: Prof. Feng Liuweb.cecs.pdx.edu/~fliu/courses/cs410/notes/Lecture8.pdfRANSAC The set of putative matches contains a very high percentage of outliers RANSAC loop: Randomly select a seed

Image alignment

◼ 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

Page 11: Prof. Feng Liuweb.cecs.pdx.edu/~fliu/courses/cs410/notes/Lecture8.pdfRANSAC The set of putative matches contains a very high percentage of outliers RANSAC loop: Randomly select a seed

Alignment as fitting

• Previous lectures: fitting a model to features in one

image

i

i Mx ),(residual

Find model M that minimizes

M

xi

Page 12: Prof. Feng Liuweb.cecs.pdx.edu/~fliu/courses/cs410/notes/Lecture8.pdfRANSAC The set of putative matches contains a very high percentage of outliers RANSAC loop: Randomly select a seed

Alignment as fitting

• Previous lectures: fitting a model to features in one

image

• Alignment: fitting a model to a transformation between

pairs of features (matches) in two images

i

i Mx ),(residual

i

ii xxT )),((residual

Find model M that minimizes

Find transformation T

that minimizes

M

xi

T

xixi'

Page 13: Prof. Feng Liuweb.cecs.pdx.edu/~fliu/courses/cs410/notes/Lecture8.pdfRANSAC The set of putative matches contains a very high percentage of outliers RANSAC loop: Randomly select a seed

2D transformation models

• Similarity

(translation,

scale, rotation)

• Affine

• Projective

(homography)

Page 14: Prof. Feng Liuweb.cecs.pdx.edu/~fliu/courses/cs410/notes/Lecture8.pdfRANSAC The set of putative matches contains a very high percentage of outliers RANSAC loop: Randomly select a seed

Let’s start with affine transformations

• Simple fitting procedure (linear least squares)

• Approximates viewpoint changes for roughly planar

objects and roughly orthographic cameras

• Can be used to initialize fitting for more complex

models

Page 15: Prof. Feng Liuweb.cecs.pdx.edu/~fliu/courses/cs410/notes/Lecture8.pdfRANSAC The set of putative matches contains a very high percentage of outliers RANSAC loop: Randomly select a seed

Fitting an affine transformation

• Assume 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

Page 16: Prof. Feng Liuweb.cecs.pdx.edu/~fliu/courses/cs410/notes/Lecture8.pdfRANSAC The set of putative matches contains a very high percentage of outliers RANSAC loop: Randomly select a seed

Fitting an affine transformation

• Assume 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

affine model parameters

Page 17: Prof. Feng Liuweb.cecs.pdx.edu/~fliu/courses/cs410/notes/Lecture8.pdfRANSAC The set of putative matches contains a very high percentage of outliers RANSAC loop: Randomly select a seed

Fitting an affine transformation

• Linear system with six unknowns

• Each match gives us two linearly

independent equations: need at least three

to solve for the transformation parameters

=

i

i

ii

ii

y

x

t

t

m

m

m

m

yx

yx

2

1

4

3

2

1

1000

0100

Page 18: Prof. Feng Liuweb.cecs.pdx.edu/~fliu/courses/cs410/notes/Lecture8.pdfRANSAC The set of putative matches contains a very high percentage of outliers RANSAC loop: Randomly select a seed

Fitting a plane projective transformation

• Homography: plane projective transformation

(transformation taking a quad to another

arbitrary quad)

Page 19: Prof. Feng Liuweb.cecs.pdx.edu/~fliu/courses/cs410/notes/Lecture8.pdfRANSAC The set of putative matches contains a very high percentage of outliers RANSAC loop: Randomly select a seed

Homography

• The transformation between two views of a planar surface

• The transformation between images from two cameras

that share the same center

Page 20: Prof. Feng Liuweb.cecs.pdx.edu/~fliu/courses/cs410/notes/Lecture8.pdfRANSAC The set of putative matches contains a very high percentage of outliers RANSAC loop: Randomly select a seed

Application: Panorama stitching

Source: Hartley & Zisserman

Page 21: Prof. Feng Liuweb.cecs.pdx.edu/~fliu/courses/cs410/notes/Lecture8.pdfRANSAC The set of putative matches contains a very high percentage of outliers RANSAC loop: Randomly select a seed

Fitting a homography

• Homogeneous coordinates

Converting to homogeneous

image coordinates

Converting from homogeneous

image coordinates

Page 22: Prof. Feng Liuweb.cecs.pdx.edu/~fliu/courses/cs410/notes/Lecture8.pdfRANSAC The set of putative matches contains a very high percentage of outliers RANSAC loop: Randomly select a seed

Fitting a homography

• Homogeneous coordinates

• Equation for homography:

Converting to homogeneous

image coordinates

Converting from homogeneous

image coordinates

=

11 333231

232221

131211

y

x

hhh

hhh

hhh

y

x

Page 23: Prof. Feng Liuweb.cecs.pdx.edu/~fliu/courses/cs410/notes/Lecture8.pdfRANSAC The set of putative matches contains a very high percentage of outliers RANSAC loop: Randomly select a seed

Fitting a homography

• Equation for homography:

ii xHx =

=

11 333231

232221

131211

i

i

i

i

y

x

hhh

hhh

hhh

y

x

0= ii xHx

=

i

T

ii

T

i

i

T

ii

T

i

T

i

T

i

i

T

i

T

i

T

i

i

yx

x

y

y

x

xhxh

xhxh

xhxh

xh

xh

xh

3

2

1

12

31

23

1

0

0

0

0

3

2

1

=

h

h

h

xx

xx

xx

TT

ii

T

ii

T

ii

TT

i

T

ii

T

i

T

xy

x

y3 equations,

only 2 linearly

independent

Page 24: Prof. Feng Liuweb.cecs.pdx.edu/~fliu/courses/cs410/notes/Lecture8.pdfRANSAC The set of putative matches contains a very high percentage of outliers RANSAC loop: Randomly select a seed

Direct linear transform

• H has 8 degrees of freedom (9 parameters, but scale is arbitrary)

• One match gives us two linearly independent equations

• Four matches needed for a minimal solution (null space of 8x9 matrix)

• More than four: homogeneous least squares

0

0

0

0

0

3

2

1111

111

=

h

h

h

xx

xx

xx

xx

T

nn

TT

n

T

nn

T

n

T

TTT

TTT

x

y

x

y

0=hA

Page 25: Prof. Feng Liuweb.cecs.pdx.edu/~fliu/courses/cs410/notes/Lecture8.pdfRANSAC The set of putative matches contains a very high percentage of outliers RANSAC loop: Randomly select a seed

Geometric approach

25

𝐻= arg min𝐻

σ𝑖=1𝑁 𝑑2 𝑥𝑖 , 𝐻𝑥𝑖

′ + 𝑑2 𝑥𝑖′, 𝐻−1𝑥𝑖

𝐻𝑥𝑖′: The location to which 𝑥𝑖

′ in Image I’ is mapped by H in Image I

Symmetric transfer error to minimize the

geometric errors

𝑑2 𝑥𝑖 , 𝐻𝑥𝑖′ : The error between the projected point and the target point

Page 26: Prof. Feng Liuweb.cecs.pdx.edu/~fliu/courses/cs410/notes/Lecture8.pdfRANSAC The set of putative matches contains a very high percentage of outliers RANSAC loop: Randomly select a seed

Robust and large-scale alignment

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

Page 27: Prof. Feng Liuweb.cecs.pdx.edu/~fliu/courses/cs410/notes/Lecture8.pdfRANSAC The set of putative matches contains a very high percentage of outliers RANSAC loop: Randomly select a seed

RANSAC

❑ The set of putative matches contains a very high

percentage of outliers

❑ RANSAC loop:

✓ Randomly select a seed group of matches

✓ Compute transformation from seed group

✓ Find inliers to this transformation

✓ If the number of inliers is sufficiently large, re-compute least-

squares estimate of transformation on all of the inliers

❑ Keep the transformation with the largest number of

inliers

Page 28: Prof. Feng Liuweb.cecs.pdx.edu/~fliu/courses/cs410/notes/Lecture8.pdfRANSAC The set of putative matches contains a very high percentage of outliers RANSAC loop: Randomly select a seed

Homework 2: Image Stitching

Feature detection using SIFT

Feature matching

Homography estimation

◼ Use RANSAC to remove feature outliers

Image warping and blending

28

Page 29: Prof. Feng Liuweb.cecs.pdx.edu/~fliu/courses/cs410/notes/Lecture8.pdfRANSAC The set of putative matches contains a very high percentage of outliers RANSAC loop: Randomly select a seed

Image warping

29

Image 1 Image 2

Page 30: Prof. Feng Liuweb.cecs.pdx.edu/~fliu/courses/cs410/notes/Lecture8.pdfRANSAC The set of putative matches contains a very high percentage of outliers RANSAC loop: Randomly select a seed

Image warping

30

Image 1

Page 31: Prof. Feng Liuweb.cecs.pdx.edu/~fliu/courses/cs410/notes/Lecture8.pdfRANSAC The set of putative matches contains a very high percentage of outliers RANSAC loop: Randomly select a seed

Image warping

31

Image 1

Page 32: Prof. Feng Liuweb.cecs.pdx.edu/~fliu/courses/cs410/notes/Lecture8.pdfRANSAC The set of putative matches contains a very high percentage of outliers RANSAC loop: Randomly select a seed

Image warping

32

Image 1

I_pano(x,y) = blend(I1(x, y), I2(H-1(x, y))

Backward warping

Page 33: Prof. Feng Liuweb.cecs.pdx.edu/~fliu/courses/cs410/notes/Lecture8.pdfRANSAC The set of putative matches contains a very high percentage of outliers RANSAC loop: Randomly select a seed

Next Time

Warping

33