lecture 11: transformations cs4670/5760: computer vision kavita bala

44
Lecture 11: Transformations CS4670/5760: Computer Vision Kavita Bala

Upload: felicia-woods

Post on 19-Dec-2015

221 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Lecture 11: Transformations CS4670/5760: Computer Vision Kavita Bala

Lecture 11: Transformations

CS4670/5760: Computer VisionKavita Bala

Page 2: Lecture 11: Transformations CS4670/5760: Computer Vision Kavita Bala

Announcements

• HW 1 FAQ pinned on Piazza• PA 1 Artifacts

– Soon voting will be set up. Please vote• PA 2 out this weekend

– Will present in class on Monday• Next Friday: in class review• Prelim: Mar 5, Thu, 7:30pm

– Call Auditorium, Kennedy Hall

Page 3: Lecture 11: Transformations CS4670/5760: Computer Vision Kavita Bala

Reading

• Szeliski: Chapter 6.1, 3.6

Page 4: Lecture 11: Transformations CS4670/5760: Computer Vision Kavita Bala

What is the geometric relationship between these two images?

?

Answer: Similarity transformation (translation, rotation, uniform scale)

Page 5: Lecture 11: Transformations CS4670/5760: Computer Vision Kavita Bala

All 2D Linear Transformations

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

• Properties of linear transformations:– Origin maps to origin– Lines map to lines– Parallel lines remain parallel– Ratios are preserved– Closed under composition

y

x

dc

ba

y

x

'

'

yx

lkji

hgfe

dcba

yx''

Page 6: Lecture 11: Transformations CS4670/5760: Computer Vision Kavita Bala

Homogeneous coordinates

Trick: add one more coordinate:

homogeneous image coordinates

Converting from homogeneous coordinates

x

y

w

(x, y, w)

w = 1 (x/w, y/w, 1)

homogeneous plane

Page 7: Lecture 11: Transformations CS4670/5760: Computer Vision Kavita Bala

Translation

• Solution: homogeneous coordinates to the rescue

Page 8: Lecture 11: Transformations CS4670/5760: Computer Vision Kavita Bala

Affine transformations

any transformation with last row [ 0 0 1 ] we call an affine transformation

Page 9: Lecture 11: Transformations CS4670/5760: Computer Vision Kavita Bala

Basic affine transformations

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

2D in-plane rotation Shear

1100

00

00

1

'

'

y

x

s

s

y

x

y

x

Scale

Page 10: Lecture 11: Transformations CS4670/5760: Computer Vision Kavita Bala

Affine Transformations

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

• 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

wyx

fedcba

wyx

100''

Page 11: Lecture 11: Transformations CS4670/5760: Computer Vision Kavita Bala

• Euclidean: translation, rotation, reflection

• Similarity: translation, rotation, uniform scale, reflection

• Affine: linear transformations + translation

Page 12: Lecture 11: Transformations CS4670/5760: Computer Vision Kavita Bala
Page 13: Lecture 11: Transformations CS4670/5760: Computer Vision Kavita Bala

2D image transformations

These transformations are a nested set of groups• Closed under composition and inverse is a member

Page 14: Lecture 11: Transformations CS4670/5760: Computer Vision Kavita Bala

Homographies

Page 15: Lecture 11: Transformations CS4670/5760: Computer Vision Kavita Bala

Reading

• Szeliski: Chapter 3.6

Page 16: Lecture 11: Transformations CS4670/5760: Computer Vision Kavita Bala

Is this an affine transformation?

Page 17: Lecture 11: Transformations CS4670/5760: Computer Vision Kavita Bala

Where do we go from here?

affine transformation

what happens when we mess with this row?

Page 18: Lecture 11: Transformations CS4670/5760: Computer Vision Kavita Bala

Projective Transformations aka Homographies aka Planar Perspective Maps

Called a homography (or planar perspective map)

Page 19: Lecture 11: Transformations CS4670/5760: Computer Vision Kavita Bala

Why do we care?

• What is the relation between a plane in the world and a perspective image of it?

• Can we reconstruct another view from one image?

• Relation between pairs of images– Need to make a mosaic

Page 20: Lecture 11: Transformations CS4670/5760: Computer Vision Kavita Bala
Page 21: Lecture 11: Transformations CS4670/5760: Computer Vision Kavita Bala

Homographies

Page 22: Lecture 11: Transformations CS4670/5760: Computer Vision Kavita Bala

Recap of 4620

Page 23: Lecture 11: Transformations CS4670/5760: Computer Vision Kavita Bala

Plane projection in drawing[C

S 41

7 Sp

ring

2002

]

23

Page 24: Lecture 11: Transformations CS4670/5760: Computer Vision Kavita Bala

Perspective projection

similar triangles:

(y’, f)

(x’, y’, w’) = (fx, fy, z)

x’ = fx/z, y’ = fy/z

Page 25: Lecture 11: Transformations CS4670/5760: Computer Vision Kavita Bala

Homographies

Page 26: Lecture 11: Transformations CS4670/5760: Computer Vision Kavita Bala

Homographies

What happens when the denominator is 0?

Page 27: Lecture 11: Transformations CS4670/5760: Computer Vision Kavita Bala

Points at infinity

Page 28: Lecture 11: Transformations CS4670/5760: Computer Vision Kavita Bala

Implications of w

• All scalar multiples of a 4-vector are equivalent• When w is not zero, can divide by w

– therefore these points represent “normal” affine points

• When w is zero, it’s a point at infinity, a.k.a. a direction– this is the point where parallel lines intersect– can also think of it as the vanishing point

28

Page 29: Lecture 11: Transformations CS4670/5760: Computer Vision Kavita Bala

29

Mas

acci

o, T

rinity

, Flo

renc

e

Page 30: Lecture 11: Transformations CS4670/5760: Computer Vision Kavita Bala
Page 31: Lecture 11: Transformations CS4670/5760: Computer Vision Kavita Bala

Consider a line through point (a, b) with slope mx’ = a + m t (line through a along direction m)if t = 1/w; x’ = (a w + m)/wIn homogeneous coordinates (aw+m, w)At w = 0, point at infinity (m,0) represents line with slope m

31

Page 32: Lecture 11: Transformations CS4670/5760: Computer Vision Kavita Bala

Image warping with homographies

image plane in front image plane belowblack areawhere no pixelmaps to

Page 33: Lecture 11: Transformations CS4670/5760: Computer Vision Kavita Bala

Homographies

Page 34: Lecture 11: Transformations CS4670/5760: Computer Vision Kavita Bala

Homographies

• Homographies …– Affine transformations, and– Projective warps

• Properties of projective 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

Page 35: Lecture 11: Transformations CS4670/5760: Computer Vision Kavita Bala

2D image transformations

These transformations are a nested set of groups• Closed under composition and inverse is a member

Page 36: Lecture 11: Transformations CS4670/5760: Computer Vision Kavita Bala
Page 37: Lecture 11: Transformations CS4670/5760: Computer Vision Kavita Bala

Image Warping

• Given a coordinate xform (x’,y’) = T(x,y) and a source image f(x,y), how do we compute an xformed image g(x’,y’) = f(T(x,y))?

f(x,y) g(x’,y’)x x’

T(x,y)y y’

Page 38: Lecture 11: Transformations CS4670/5760: Computer Vision Kavita Bala

Forward Warping

• Send each pixel f(x) to its corresponding location (x’,y’) = T(x,y) in g(x’,y’)

f(x,y) g(x’,y’)x x’

T(x,y)y y’

Page 39: Lecture 11: Transformations CS4670/5760: Computer Vision Kavita Bala
Page 40: Lecture 11: Transformations CS4670/5760: Computer Vision Kavita Bala

Forward Warping

• Send each pixel f(x,y) to its corresponding location x’ = h(x,y) in g(x’,y’)

f(x,y) g(x’,y’)x x’

T(x,y)

• What if pixel lands “between” pixels?• Answer: add “contribution” to several pixels,

normalize later (splatting)• Problem? Can still result in holes

y y’

Page 41: Lecture 11: Transformations CS4670/5760: Computer Vision Kavita Bala

Inverse Warping

• Get each pixel g(x’,y’) from its corresponding location (x,y) = T-1(x,y) in f(x,y)

f(x,y) g(x’,y’)x x’

T-1(x,y)

• Requires taking the inverse of the transform• What if pixel comes from “between” pixels?

y y’

Page 42: Lecture 11: Transformations CS4670/5760: Computer Vision Kavita Bala

Inverse Warping

• Get each pixel g(x’) from its corresponding location x’ = h(x) in f(x)• What if pixel comes from “between” two pixels?• Answer: resample color value from interpolated

(prefiltered) source image

f(x,y) g(x’,y’)x x’

y y’T-1(x,y)

Page 43: Lecture 11: Transformations CS4670/5760: Computer Vision Kavita Bala
Page 44: Lecture 11: Transformations CS4670/5760: Computer Vision Kavita Bala

Interpolation

• Possible interpolation filters:– nearest neighbor– bilinear– bicubic (interpolating)– sinc

• Needed to prevent “jaggies” and “texture crawl”

(with prefiltering)