Image Formation I Chapter 1 (Forsyth&Ponce)...

40
Image Formation I Chapter 1 (Forsyth&Ponce) Cameras Guido Gerig CS-GY 6643, Spring 2017 Acknowledgements: Slides used from Prof. Trevor Darrell, (http://www.eecs.berkeley.edu/~trevor/CS280.html) Some slides modified from Marc Pollefeys, UNC Chapel Hill. Other slides and illustrations from J. Ponce, addendum to course book.

Transcript of Image Formation I Chapter 1 (Forsyth&Ponce)...

Page 1: Image Formation I Chapter 1 (Forsyth&Ponce) Camerasengineering.nyu.edu/.../Materials/CS6643-CV-S2017-Ch1-1.pdf · 2 3 1. pixel coordinates. world coordinates. Conversion back from

Image Formation IChapter 1 (Forsyth&Ponce)

CamerasGuido Gerig

CS-GY 6643, Spring 2017

Acknowledgements: • Slides used from Prof. Trevor Darrell,

(http://www.eecs.berkeley.edu/~trevor/CS280.html)• Some slides modified from Marc Pollefeys, UNC Chapel Hill. Other

slides and illustrations from J. Ponce, addendum to course book.

Page 2: Image Formation I Chapter 1 (Forsyth&Ponce) Camerasengineering.nyu.edu/.../Materials/CS6643-CV-S2017-Ch1-1.pdf · 2 3 1. pixel coordinates. world coordinates. Conversion back from

GEOMETRIC CAMERA MODELS

• The Intrinsic Parameters of a Camera

• The Extrinsic Parameters of a Camera

• The General Form of the Perspective Projection Equation

• Line Geometry

Reading: Chapter 1.

Page 3: Image Formation I Chapter 1 (Forsyth&Ponce) Camerasengineering.nyu.edu/.../Materials/CS6643-CV-S2017-Ch1-1.pdf · 2 3 1. pixel coordinates. world coordinates. Conversion back from

Images are two-dimensional patterns of brightness values.

They are formed by the projection of 3D objects.

Figure from US Navy Manual of Basic Optics and Optical Instruments, prepared by Bureau of Naval Personnel. Reprinted by Dover Publications, Inc., 1969.

Page 4: Image Formation I Chapter 1 (Forsyth&Ponce) Camerasengineering.nyu.edu/.../Materials/CS6643-CV-S2017-Ch1-1.pdf · 2 3 1. pixel coordinates. world coordinates. Conversion back from

Animal eye:a looonnng time ago.

Pinhole perspective projection: Brunelleschi, XVth Century.Camera obscura: XVIth Century.

Photographic camera:Niepce, 1816.

Page 5: Image Formation I Chapter 1 (Forsyth&Ponce) Camerasengineering.nyu.edu/.../Materials/CS6643-CV-S2017-Ch1-1.pdf · 2 3 1. pixel coordinates. world coordinates. Conversion back from

Camera model

Relation between pixels and rays in space

?

Page 6: Image Formation I Chapter 1 (Forsyth&Ponce) Camerasengineering.nyu.edu/.../Materials/CS6643-CV-S2017-Ch1-1.pdf · 2 3 1. pixel coordinates. world coordinates. Conversion back from

Camera obscura + lens

The camera obscura (Latin for 'dark room') is an optical device that projects an image of its surroundings on a screen (source Wikipedia).

Page 7: Image Formation I Chapter 1 (Forsyth&Ponce) Camerasengineering.nyu.edu/.../Materials/CS6643-CV-S2017-Ch1-1.pdf · 2 3 1. pixel coordinates. world coordinates. Conversion back from

Limits for pinhole cameras

Page 8: Image Formation I Chapter 1 (Forsyth&Ponce) Camerasengineering.nyu.edu/.../Materials/CS6643-CV-S2017-Ch1-1.pdf · 2 3 1. pixel coordinates. world coordinates. Conversion back from

Physical parameters of image formation

• Geometric– Type of projection– Camera pose

• Optical– Sensor’s lens type– focal length, field of view, aperture

• Photometric– Type, direction, intensity of light reaching sensor– Surfaces’ reflectance properties

• Sensor– sampling, etc.

Page 9: Image Formation I Chapter 1 (Forsyth&Ponce) Camerasengineering.nyu.edu/.../Materials/CS6643-CV-S2017-Ch1-1.pdf · 2 3 1. pixel coordinates. world coordinates. Conversion back from

Perspective and art• Use of correct perspective projection indicated in 1st

century B.C. frescoes• Skill resurfaces in Renaissance: artists develop

systematic methods to determine perspective projection (around 1480-1515)

Durer, 1525RaphaelK. Grauman

Page 10: Image Formation I Chapter 1 (Forsyth&Ponce) Camerasengineering.nyu.edu/.../Materials/CS6643-CV-S2017-Ch1-1.pdf · 2 3 1. pixel coordinates. world coordinates. Conversion back from

Perspective projection equations

• 3d world mapped to 2d projection in image plane

Forsyth and Ponce

Camera frame

Image plane

Optical axis

Focal length

Scene / world points

Scene point Image coordinates

‘’‘’

Page 11: Image Formation I Chapter 1 (Forsyth&Ponce) Camerasengineering.nyu.edu/.../Materials/CS6643-CV-S2017-Ch1-1.pdf · 2 3 1. pixel coordinates. world coordinates. Conversion back from

Affine projection models: Weak perspective projection

0

'where''

zfm

myymxx

=

−=−=

is the magnification.

When the scene relief is small compared to its distance from theCamera, m can be taken constant: weak perspective projection.

Page 12: Image Formation I Chapter 1 (Forsyth&Ponce) Camerasengineering.nyu.edu/.../Materials/CS6643-CV-S2017-Ch1-1.pdf · 2 3 1. pixel coordinates. world coordinates. Conversion back from

Affine projection models: Orthographic projection

==

yyxx

'' When the camera is at a

(roughly constant) distancefrom the scene, take m=1.

Page 13: Image Formation I Chapter 1 (Forsyth&Ponce) Camerasengineering.nyu.edu/.../Materials/CS6643-CV-S2017-Ch1-1.pdf · 2 3 1. pixel coordinates. world coordinates. Conversion back from

Example Orthographic Projection

Projection of a single view of an object (as a view of the front) onto a drawing surface (in which the lines of projection are perpendicular to the drawing surface). Source: Merriam-Webster

Page 14: Image Formation I Chapter 1 (Forsyth&Ponce) Camerasengineering.nyu.edu/.../Materials/CS6643-CV-S2017-Ch1-1.pdf · 2 3 1. pixel coordinates. world coordinates. Conversion back from

Homogeneous coordinatesIs 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

Slide by Steve Seitz

Page 15: Image Formation I Chapter 1 (Forsyth&Ponce) Camerasengineering.nyu.edu/.../Materials/CS6643-CV-S2017-Ch1-1.pdf · 2 3 1. pixel coordinates. world coordinates. Conversion back from

Perspective Projection Matrix

divide by the third coordinate to convert back to non-homogeneous coordinates

• Projection is a matrix multiplication using homogeneous coordinates:

=

'/1

0'/10000100001

fzyx

zyx

f)','(

zyf

zxf⇒

Slide by Steve Seitz

Complete mapping from world points to image pixel positions?

Page 16: Image Formation I Chapter 1 (Forsyth&Ponce) Camerasengineering.nyu.edu/.../Materials/CS6643-CV-S2017-Ch1-1.pdf · 2 3 1. pixel coordinates. world coordinates. Conversion back from

Points at infinity, vanishing points

Points from infinity representrays into camera which are close to the optical axis.

Image source: wikipedia

Page 17: Image Formation I Chapter 1 (Forsyth&Ponce) Camerasengineering.nyu.edu/.../Materials/CS6643-CV-S2017-Ch1-1.pdf · 2 3 1. pixel coordinates. world coordinates. Conversion back from

Perspective projection & calibration• Perspective equations so far in terms of camera’s

reference frame….• Camera’s intrinsic and extrinsic parameters needed

to calibrate geometry.

Camera frame

K. Grauman

Page 18: Image Formation I Chapter 1 (Forsyth&Ponce) Camerasengineering.nyu.edu/.../Materials/CS6643-CV-S2017-Ch1-1.pdf · 2 3 1. pixel coordinates. world coordinates. Conversion back from

The CCD camera

Page 19: Image Formation I Chapter 1 (Forsyth&Ponce) Camerasengineering.nyu.edu/.../Materials/CS6643-CV-S2017-Ch1-1.pdf · 2 3 1. pixel coordinates. world coordinates. Conversion back from

Perspective projection & calibration

Camera frame

Intrinsic:Image coordinates relative to camera Pixel coordinates

Extrinsic:Camera frame World frame

World frame

World to camera coord. trans. matrix

(4x4)

Perspectiveprojection matrix

(3x4)

Camera to pixel coord.

trans. matrix (3x3)

=2D

point(3x1)

3Dpoint(4x1)

K. Grauman

Page 20: Image Formation I Chapter 1 (Forsyth&Ponce) Camerasengineering.nyu.edu/.../Materials/CS6643-CV-S2017-Ch1-1.pdf · 2 3 1. pixel coordinates. world coordinates. Conversion back from

Intrinsic parameters: from idealized world coordinates to pixel values

Forsyth&Ponce

zyfvzxfu

=

=Perspective projection

W. Freeman

Page 21: Image Formation I Chapter 1 (Forsyth&Ponce) Camerasengineering.nyu.edu/.../Materials/CS6643-CV-S2017-Ch1-1.pdf · 2 3 1. pixel coordinates. world coordinates. Conversion back from

Intrinsic parameters

zyvzxu

α

α

=

=But “pixels” are in some arbitrary spatial units

W. Freeman

Page 22: Image Formation I Chapter 1 (Forsyth&Ponce) Camerasengineering.nyu.edu/.../Materials/CS6643-CV-S2017-Ch1-1.pdf · 2 3 1. pixel coordinates. world coordinates. Conversion back from

Intrinsic parameters

zyvzxu

β

α

=

=Maybe pixels are not square

W. Freeman

Page 23: Image Formation I Chapter 1 (Forsyth&Ponce) Camerasengineering.nyu.edu/.../Materials/CS6643-CV-S2017-Ch1-1.pdf · 2 3 1. pixel coordinates. world coordinates. Conversion back from

Intrinsic parameters

0

0

vzyv

uzxu

+=

+=

β

αWe don’t know the origin of our camera pixel coordinates

W. Freeman

Page 24: Image Formation I Chapter 1 (Forsyth&Ponce) Camerasengineering.nyu.edu/.../Materials/CS6643-CV-S2017-Ch1-1.pdf · 2 3 1. pixel coordinates. world coordinates. Conversion back from

Intrinsic parameters

0

0

)sin(

)cot(

vzyv

uzy

zxu

+=

+−=

θβ

θαα

May be skew between camera pixel axes

v

θu

v′

u′

vuvuuvv

)cot()cos()sin(

θθθ

−=′−=′=′

W. Freeman

Page 25: Image Formation I Chapter 1 (Forsyth&Ponce) Camerasengineering.nyu.edu/.../Materials/CS6643-CV-S2017-Ch1-1.pdf · 2 3 1. pixel coordinates. world coordinates. Conversion back from

pz

p C (K) 1 =

Intrinsic parameters, homogeneous coordinates

0

0

)sin(

)cot(

vzyv

uzy

zxu

+=

+−=

θβ

θαα

=

1000

100)sin(

0

)cot(1

10

0

zyx

v

u

zvu

θβ

θααUsing homogenous coordinates,we can write this as:

or:

In camera-based coords

In pixels

W. Freeman

Page 26: Image Formation I Chapter 1 (Forsyth&Ponce) Camerasengineering.nyu.edu/.../Materials/CS6643-CV-S2017-Ch1-1.pdf · 2 3 1. pixel coordinates. world coordinates. Conversion back from

Perspective projection & calibration

Camera frame

Intrinsic:Image coordinates relative to camera Pixel coordinates

Extrinsic:Camera frame World frame

World frame

World to camera coord. trans. matrix

(4x4)

Perspectiveprojection matrix

(3x4)

Camera to pixel coord.

trans. matrix (3x3)

=2D

point(3x1)

3Dpoint(4x1)

K. Grauman

Page 27: Image Formation I Chapter 1 (Forsyth&Ponce) Camerasengineering.nyu.edu/.../Materials/CS6643-CV-S2017-Ch1-1.pdf · 2 3 1. pixel coordinates. world coordinates. Conversion back from

Coordinate Changes: Pure Translations

OBP = OBOA + OAP , BP = AP + BOA

Page 28: Image Formation I Chapter 1 (Forsyth&Ponce) Camerasengineering.nyu.edu/.../Materials/CS6643-CV-S2017-Ch1-1.pdf · 2 3 1. pixel coordinates. world coordinates. Conversion back from

Coordinate Changes: Pure Rotations

),,(.........

AB

AB

AB

BABABA

BABABA

BABABABA R kji

kkkjkijkjjjiikijii

=

= [ ]A

BA

BA

B kji=

=TB

A

TB

A

TB

A

kji

Page 29: Image Formation I Chapter 1 (Forsyth&Ponce) Camerasengineering.nyu.edu/.../Materials/CS6643-CV-S2017-Ch1-1.pdf · 2 3 1. pixel coordinates. world coordinates. Conversion back from

Coordinate Changes: Rotations about the k Axis

−=

1000cossin0sincos

θθθθ

RBA

Page 30: Image Formation I Chapter 1 (Forsyth&Ponce) Camerasengineering.nyu.edu/.../Materials/CS6643-CV-S2017-Ch1-1.pdf · 2 3 1. pixel coordinates. world coordinates. Conversion back from

A rotation matrix is characterized by the following properties:

• Its inverse is equal to its transpose, and

• its determinant is equal to 1.

Or equivalently:

• Its rows (or columns) form a right-handedorthonormal coordinate system.

Page 31: Image Formation I Chapter 1 (Forsyth&Ponce) Camerasengineering.nyu.edu/.../Materials/CS6643-CV-S2017-Ch1-1.pdf · 2 3 1. pixel coordinates. world coordinates. Conversion back from

Coordinate Changes: Pure Rotations

[ ] [ ]

PRP

zyx

zyx

OP

ABA

B

B

B

B

BBBA

A

A

AAA

=⇒

=

= kjikji

Page 32: Image Formation I Chapter 1 (Forsyth&Ponce) Camerasengineering.nyu.edu/.../Materials/CS6643-CV-S2017-Ch1-1.pdf · 2 3 1. pixel coordinates. world coordinates. Conversion back from

Coordinate Changes: Rigid Transformations

ABAB

AB OPRP +=

Page 33: Image Formation I Chapter 1 (Forsyth&Ponce) Camerasengineering.nyu.edu/.../Materials/CS6643-CV-S2017-Ch1-1.pdf · 2 3 1. pixel coordinates. world coordinates. Conversion back from

Block Matrix Multiplication

=

=

2221

1211

2221

1211

BBBB

BAAAA

A

What is AB ?

++++

=2222122121221121

2212121121121111

BABABABABABABABA

AB

Homogeneous Representation of Rigid Transformations

=

+=

=

11111P

TOPRPORP A

BA

ABAB

AA

TA

BBA

B

0

T: Transformation

Page 34: Image Formation I Chapter 1 (Forsyth&Ponce) Camerasengineering.nyu.edu/.../Materials/CS6643-CV-S2017-Ch1-1.pdf · 2 3 1. pixel coordinates. world coordinates. Conversion back from

Extrinsic parameters: translation and rotation of camera frame

tpRp CW

WCW

C += Non-homogeneous

coordinates

Homogeneous coordinates

−−−−−−−−

=

ptRp WC

WC

WC

1000|

|

W. Freeman

Page 35: Image Formation I Chapter 1 (Forsyth&Ponce) Camerasengineering.nyu.edu/.../Materials/CS6643-CV-S2017-Ch1-1.pdf · 2 3 1. pixel coordinates. world coordinates. Conversion back from

Combining extrinsic and intrinsic calibration parameters, in homogeneous coordinates

Forsyth&Ponce

ptR

Kp WC

WC

W

10,0,0z

1

=

pp C K z1 =

pMp W z1 =

Intrinsic

Extrinsic

−−−−−−−−

=

ptRp WC

WC

WC

1000|

|World coordinates

Camera coordinates

pixels

W. Freeman

Page 36: Image Formation I Chapter 1 (Forsyth&Ponce) Camerasengineering.nyu.edu/.../Materials/CS6643-CV-S2017-Ch1-1.pdf · 2 3 1. pixel coordinates. world coordinates. Conversion back from

Other ways to write the same equation

=

1.........

1

1 3

2

1

zW

yW

xW

T

T

T

ppp

mmm

zvu

pMz

p W 1=

pixel coordinates

world coordinates

Conversion back from homogeneous coordinates leads to (note that z = mT

3*P) :

W. Freeman

?

Page 37: Image Formation I Chapter 1 (Forsyth&Ponce) Camerasengineering.nyu.edu/.../Materials/CS6643-CV-S2017-Ch1-1.pdf · 2 3 1. pixel coordinates. world coordinates. Conversion back from

Other ways to write the same equation

=

1.........

1

1 3

2

1

zW

yW

xW

T

T

T

ppp

mmm

zvu

pMz

p W 1=

PmPmv

PmPmu

⋅⋅

=

⋅⋅

=

3

2

3

1

pixel coordinates

world coordinates

Conversion back from homogeneous coordinates leads to (note that z = mT

3*P) :

W. FreemanZ is not independent of M and P!

Page 38: Image Formation I Chapter 1 (Forsyth&Ponce) Camerasengineering.nyu.edu/.../Materials/CS6643-CV-S2017-Ch1-1.pdf · 2 3 1. pixel coordinates. world coordinates. Conversion back from

Extrinsic Parameters

Page 39: Image Formation I Chapter 1 (Forsyth&Ponce) Camerasengineering.nyu.edu/.../Materials/CS6643-CV-S2017-Ch1-1.pdf · 2 3 1. pixel coordinates. world coordinates. Conversion back from

Explicit Form of the Projection Matrix

Note:

M is only defined up to scale in this setting!!

Page 40: Image Formation I Chapter 1 (Forsyth&Ponce) Camerasengineering.nyu.edu/.../Materials/CS6643-CV-S2017-Ch1-1.pdf · 2 3 1. pixel coordinates. world coordinates. Conversion back from

Calibration target

http://www.kinetic.bc.ca/CompVision/opti-CAL.html

Find the position, ui and vi, in pixels, of each calibration object feature point.