cs 691b computational photography instructor: gianfranco doretto 3d to 2d projections

43
CS 691B Computational Photography Instructor: Gianfranco Doretto 3D to 2D Projections

Upload: dennis-wheeler

Post on 21-Jan-2016

215 views

Category:

Documents


2 download

TRANSCRIPT

Page 1: CS 691B Computational Photography Instructor: Gianfranco Doretto 3D to 2D Projections

CS 691B Computational Photography

Instructor: Gianfranco Doretto3D to 2D Projections

Page 2: CS 691B Computational Photography Instructor: Gianfranco Doretto 3D to 2D Projections

Pinhole camera model

• Pinhole model:– Captures pencil of rays – all rays through a single point– The point is called Center of Projection (COP)– The image is formed on the Image Plane– Effective focal length f is distance from COP to Image

Plane

Page 3: CS 691B Computational Photography Instructor: Gianfranco Doretto 3D to 2D Projections

Point of observation

Dimensionality Reduction Machine (3D to 2D)

3D world 2D image

What have we lost?• Angles• Distances (lengths)

Page 4: CS 691B Computational Photography Instructor: Gianfranco Doretto 3D to 2D Projections

Projection can be tricky…

Slide source: Seitz

Page 5: CS 691B Computational Photography Instructor: Gianfranco Doretto 3D to 2D Projections

Projection can be tricky…

Slide source: Seitz

Page 6: CS 691B Computational Photography Instructor: Gianfranco Doretto 3D to 2D Projections

Projective Geometry

What is lost?• Length

Which is closer?

Who is taller?

Page 7: CS 691B Computational Photography Instructor: Gianfranco Doretto 3D to 2D Projections

Lengths can’t be trusted...

B’

C’

A’

Page 8: CS 691B Computational Photography Instructor: Gianfranco Doretto 3D to 2D Projections

…but humans adopt!

http://www.michaelbach.de/ot/sze_muelue/index.html

Müller-Lyer Illusion

We don’t make measurements in the image plane

Page 9: CS 691B Computational Photography Instructor: Gianfranco Doretto 3D to 2D Projections

Projective Geometry

What is lost?• Length• Angles

Perpendicular?

Parallel?

Page 10: CS 691B Computational Photography Instructor: Gianfranco Doretto 3D to 2D Projections

Parallel lines aren’t…

Page 11: CS 691B Computational Photography Instructor: Gianfranco Doretto 3D to 2D Projections

Projective Geometry

What is preserved?• Straight lines are still straight

Page 12: CS 691B Computational Photography Instructor: Gianfranco Doretto 3D to 2D Projections

Vanishing points and lines

Parallel lines in the world intersect in the image at a “vanishing point”

Page 13: CS 691B Computational Photography Instructor: Gianfranco Doretto 3D to 2D Projections

Vanishing points and lines

oVanishing Point oVanishing Point

Vanishing Line

Page 14: CS 691B Computational Photography Instructor: Gianfranco Doretto 3D to 2D Projections

Vanishing points and lines

Vanishing point

Vanishing line

Vanishing point

Vertical vanishing point

(at infinity)

Credit: Criminisi

Page 15: CS 691B Computational Photography Instructor: Gianfranco Doretto 3D to 2D Projections

Vanishing points and lines

Photo from online Tate collection

Page 16: CS 691B Computational Photography Instructor: Gianfranco Doretto 3D to 2D Projections

Note on estimating vanishing points

Use multiple lines for better accuracy… but lines will not intersect at exactly the same point in practice

One solution: take mean of intersecting pairs… bad idea!

Instead, minimize angular differences

Page 17: CS 691B Computational Photography Instructor: Gianfranco Doretto 3D to 2D Projections

Vanishing objects

Page 18: CS 691B Computational Photography Instructor: Gianfranco Doretto 3D to 2D Projections

Modeling projection

• The coordinate system– We will use the pin-hole model as an approximation– Put the optical center (Center Of Projection) at the origin– Put the image plane (Projection Plane) in front of the COP

• Why?

– The camera looks down the negative z axis• we need this if we want right-handed-coordinates

Page 19: CS 691B Computational Photography Instructor: Gianfranco Doretto 3D to 2D Projections

Modeling projection

• Projection equations– Compute intersection with PP of ray from (x,y,z) to COP– Derived using similar triangles (on board)

• We get the projection by throwing out the last coordinate:

Page 20: CS 691B Computational Photography Instructor: Gianfranco Doretto 3D to 2D Projections

Homogeneous coordinates• Is this a linear transformation?

Trick: add one more coordinate:

homogeneous image coordinates

homogeneous scene coordinates

Converting from homogeneous coordinates

• no—division by z is nonlinear

Page 21: CS 691B Computational Photography Instructor: Gianfranco Doretto 3D to 2D Projections

Homogeneous coordinates

Invariant to scaling

Point in Cartesian is ray in Homogeneous

wywx

kwkykwkx

kw

ky

kx

w

y

x

k

Homogeneous Coordinates

Cartesian Coordinates

Page 22: CS 691B Computational Photography Instructor: Gianfranco Doretto 3D to 2D Projections

Perspective Projection• Projection is a matrix multiply using homogeneous coordinates:

divide by third coordinate

This is known as perspective projection• The matrix is the projection matrix• Can also formulate as a 4x4

divide by fourth coordinate

Page 23: CS 691B Computational Photography Instructor: Gianfranco Doretto 3D to 2D Projections

Orthographic Projection

• Special case of perspective projection– Distance from the COP to the PP is infinite

– Also called “parallel projection”– What’s the projection matrix?

Image World

Page 24: CS 691B Computational Photography Instructor: Gianfranco Doretto 3D to 2D Projections

Scaled Orthographic Projection

• Special case of perspective projection– Object dimensions are small compared to

distance to camera

– Also called “weak perspective”– What’s the projection matrix?

1000

000

000

z

y

x

s

f

f

w

v

u

Page 25: CS 691B Computational Photography Instructor: Gianfranco Doretto 3D to 2D Projections

Spherical Projection

• What if PP is spherical with center at COP?• In spherical coordinates, projection is trivial:• (θ,Φ) = (θ,Φ,d)• Note: doesn’t depend on focal length!

Page 26: CS 691B Computational Photography Instructor: Gianfranco Doretto 3D to 2D Projections

Projection matrix

XtRKx x: Image Coordinates: w(u,v,1)K: Intrinsic Matrix (3x3)R: Rotation (3x3) t: Translation (3x1)X: World Coordinates: (X,Y,Z,1)

Ow

iw

kw

jw

R,T

Page 27: CS 691B Computational Photography Instructor: Gianfranco Doretto 3D to 2D Projections

X0IKx

10100

000

000

1z

y

x

f

f

v

u

w

K

Projection matrix

Intrinsic Assumptions• Unit aspect ratio• Principal point at (0,0)• No skew

Extrinsic Assumptions• No rotation• Camera at (0,0,0)

Page 28: CS 691B Computational Photography Instructor: Gianfranco Doretto 3D to 2D Projections

Remove assumption: known optical center

X0IKx

10100

00

00

10

0

z

y

x

vf

uf

v

u

w

Intrinsic Assumptions• Unit aspect ratio• No skew

Extrinsic Assumptions• No rotation• Camera at (0,0,0)

Page 29: CS 691B Computational Photography Instructor: Gianfranco Doretto 3D to 2D Projections

Remove assumption: square pixels

X0IKx

10100

00

00

10

0

z

y

x

v

u

v

u

w

Intrinsic Assumptions• No skew

Extrinsic Assumptions• No rotation• Camera at (0,0,0)

Page 30: CS 691B Computational Photography Instructor: Gianfranco Doretto 3D to 2D Projections

Remove assumption: non-skewed pixels

X0IKx

10100

00

0

10

0

z

y

x

v

us

v

u

w

Intrinsic Assumptions Extrinsic Assumptions• No rotation• Camera at (0,0,0)

Note: different books use different notation for parameters

Page 31: CS 691B Computational Photography Instructor: Gianfranco Doretto 3D to 2D Projections

Oriented and Translated Camera

Ow

iw

kw

jw

t

R

Page 32: CS 691B Computational Photography Instructor: Gianfranco Doretto 3D to 2D Projections

Allow camera translation

XtIKx

1100

010

001

100

0

0

10

0

z

y

x

t

t

t

v

u

v

u

w

z

y

x

Intrinsic Assumptions Extrinsic Assumptions• No rotation

Page 33: CS 691B Computational Photography Instructor: Gianfranco Doretto 3D to 2D Projections

3D Rotation of Points

Rotation around the coordinate axes, counter-clockwise:

100

0cossin

0sincos

)(

cos0sin

010

sin0cos

)(

cossin0

sincos0

001

)(

z

y

x

R

R

R

p

p’

y

z

Slide Credit: Saverese

Page 34: CS 691B Computational Photography Instructor: Gianfranco Doretto 3D to 2D Projections

Allow camera rotation

XtRKx

1100

0

1 333231

232221

131211

0

0

z

y

x

trrr

trrr

trrr

v

us

v

u

w

z

y

x

Page 35: CS 691B Computational Photography Instructor: Gianfranco Doretto 3D to 2D Projections

Degrees of freedom

XtRKx

1100

0

1 333231

232221

131211

0

0

z

y

x

trrr

trrr

trrr

v

us

v

u

w

z

y

x

5 6

Page 36: CS 691B Computational Photography Instructor: Gianfranco Doretto 3D to 2D Projections

Vanishing Point = Projection from Infinity

R

R

R

z

y

x

z

y

x

z

y

x

KpKRptRKp

0

R

R

R

z

y

x

vf

uf

v

u

w

100

0

0

10

0 0uz

fxu

R

R

0vz

fyv

R

R

Page 37: CS 691B Computational Photography Instructor: Gianfranco Doretto 3D to 2D Projections

Lens Flaws

Page 38: CS 691B Computational Photography Instructor: Gianfranco Doretto 3D to 2D Projections

Lens Flaws: Chromatic Aberration

• Dispersion: wavelength-dependent refractive index– (enables prism to spread white light beam into rainbow)

• Modifies ray-bending and lens focal length: f(λ)

• color fringes near edges of image• Corrections: add ‘doublet’

lens of flint glass, etc.

Page 39: CS 691B Computational Photography Instructor: Gianfranco Doretto 3D to 2D Projections

Chromatic Aberration

Near Lens Center Near Lens Outer Edge

Page 40: CS 691B Computational Photography Instructor: Gianfranco Doretto 3D to 2D Projections

Radial Distortion (e.g. ‘Barrel’ and ‘pin-cushion’)

straight lines curve around the image center

Page 41: CS 691B Computational Photography Instructor: Gianfranco Doretto 3D to 2D Projections

Radial Distortion

• Radial distortion of the image– Caused by imperfect lenses– Deviations are most noticeable for rays

that pass through the edge of the lens

No distortion Pin cushion Barrel

Page 42: CS 691B Computational Photography Instructor: Gianfranco Doretto 3D to 2D Projections

Radial Distortion

Page 43: CS 691B Computational Photography Instructor: Gianfranco Doretto 3D to 2D Projections

Slide Credits

• This set of sides also contains contributionskindly made available by the following authors– Alexei Efros– Stephen E. Palmer– Steve Seitz– Derek Hoiem– David Forsyth– George Bebis– Silvio Savarese