Perspective projection and Transformations
The pinhole camera
The pinhole camera P = (X,,) p = (x,y) O λ = 0 Q λ = O λ = 1 Q λ = P =-1 Q λ X = 0 + λ X 0, 0 + λ 0, 0 + λ 0 = (λx, λ, λ)
The pinhole camera Pinhole camera collapses ray OP to point p Any point on ray OP = O + λ P O = λx, λ, λ For this point to lie on =-1 plane: λ = 1 λ = 1 Coordinates of point p: P = (X,,) O p = (x,y) ( X,, )=( X,, 1) X =-1
The projection equation A point P = (X,, ) in 3D projects to a point p = (x,y) in the image x = X y = But pinhole camera s image is inverted, invert it back! x = X y =
Another derivation P = (X,,) O 1 = y 1 y p = (x,y,z)
A virtual image plane A pinhole camera produces an inverted image Imagine a virtual image plane in the front of the camera P P 1 y O y 1 O
The projection equation x = X y =
Consequence 1: Farther away objects are smaller (X, + h, ) (X,, ) Image of foot: Image of head: ( X, ) ( X, + h ) + h = h
Consequence 2: Parallel lines converge at a point Point on a line passing through point A with direction D: Q λ = A + λd Parallel lines have the same direction but pass through different points Q λ = A + λd R λ = B + λd
Consequence 2: Parallel lines converge at a point Parallel lines have the same direction but pass through different points Q λ = A + λd R λ = B + λd A = A 7, A 8, A 9 B = B 7, B 8, B 9 D = D 7, D 8, D 9
Consequence 2: Parallel lines converge at a point Q λ = A 7 + λd 7, A 8 + λd 8, A 9 + λd 9 R λ = B 7 + λd 7, B 8 + λd 8, B 9 + λd 9 q λ = ; <=>? < ; @ =>? @, ; A=>? A ; @ =>? @ r λ = C <=>? < C @ =>? @, C A=>? A C @ =>? @ Need to look at these points as goes to infinity Same as λ
Consequence 2: Parallel lines converge at a point q λ = ; <=>? < ; @ =>? @, ; A=>? A ; @ =>? @ r λ = C <=>? < C @ =>? @, C A=>? A C @ =>? @ lim!1 A X + D X A + D = lim!1 A X + D X A + D = D X D lim!1 q( )=( D X D, D D ) lim!1 r( )=( D X D, D D )
Consequence 2: Parallel lines converge at a point Parallel lines have the same direction but pass through different points Q λ = A + λd R λ = B + λd Parallel lines converge at the same point (? <? @,? A? @ ) This point of convergence is called the vanishing point What happens if D 9 = 0?
Consequence 2: Parallel lines converge at a point
What about planes? N X X + N + N = d ) N X X + N + N = d ) N X x + N y + N = d Take the limit as approaches infinity N X x + N y + N =0 Vanishing line of a plane
Changing coordinate systems P = (X,,) O O X X
Changing coordinate systems O X X
Changing coordinate systems O X
Changing coordinate systems O X
Changing coordinate systems O X
Changing coordinate systems O X
Rotations and translations How do you represent a rotation? A point in 3D: (X,,) Rotations can be represented as a matrix multiplication v 0 = Rv What are the properties of rotation matrices?
Properties of rotation matrices Rotation does not change the length of vectors v 0 = Rv kv 0 k 2 = v 0T v 0 = v T R T Rv kvk 2 = v T v ) R T R = I
Properties of rotation matrices ) R T R = I ) det(r) 2 =1 ) det(r) =±1 det(r) =1 det(r) = 1 Rotation Reflection
Rotation matrices Rotations in 3D have an axis and an angle Axis: vector that does not change when rotated Rv = v Rotation matrix has eigenvector that has eigenvalue 1
Rotation matrices from axis and angle Rotation matrix for rotation about axis v and θ First define the following matrix [v] = 2 4 0 v z v y v z 0 v x v y v x 0 Interesting fact: this matrix represents cross product [v] x = v x 3 5
Rotation matrices from axis and angle Rotation matrix for rotation about axis v and θ Rodrigues formula for rotation matrices R = I +(sin )[v] +(1 cos )[v] 2
Translations x 0 = x + t Can this be written as a matrix multiplication?
Putting everything together Change coordinate system so that center of the coordinate system is at pinhole and axis is along viewing direction x 0 w = Rx w + t Perspective projection x 0 w (X,, ) x 0 img (x, y) x = X y =
The projection equation x = X y = Is this equation linear? Can this equation be represented by a matrix multiplication?
Is projection linear? X 0 = ax + b 0 = a + b 0 = a + b x 0 = ax + b a + b y 0 = a + b a + b
Can projection be represented as a matrix multiplication? Matrix multiplication apple a b c p q r 2 3 X 4 5 = apple ax + b + c px + q + r Perspective projection x = X y =
The space of rays Every point on a ray maps it to a point on image plane Perspective projection maps rays to points All points (λx, λy, λ) map to the same image point (x,y,1) (λx, λy, λ) (x,y,1) O
Projective space R 2 Standard 2D space (plane) : Each point represented by 2 coordinates (x,y) Projective 2D space (plane) P 2 : Each point represented by 3 coordinates (x,y,z), BUT: λx, λy, λz x, y, z Mapping R 2 to P 2 (points to rays): (x, y)! (x, y, 1) Mapping to R 2 (rays to points): P 2 (x, y, z)! ( x z, y z )
Projective space and homogenous coordinates Mapping to (points to rays): R 2 P 2 Mapping to (rays to points): (x, y)! (x, y, 1) P 2 R 2 (x, y, z)! ( x z, y z ) A change of coordinates Also called homogenous coordinates
Homogenous coordinates In standard Euclidean coordinates 2D points : (x,y) 3D points : (x,y,z) In homogenous coordinates 2D points : (x,y,1) 3D points : (x,y,z,1)
Why homogenous coordinates? 2 1 0 0 3 0 40 1 0 05 0 0 1 0 2 3 X 6 4 1 7 5 = 2 3 X 4 5 2 4 X 1 3 5 Homogenous coordinates of world point Homogenous coordinates of image point
Why homogenous coordinates? 2 1 0 0 3 0 40 1 0 05 0 0 1 0 2 3 X 6 4 1 7 5 = 2 3 X 4 5 2 4 X 1 3 5 P~x w = ~x img Perspective projection is matrix multiplication in homogenous coordinates!
Why homogenous coordinates? 2 3 2 3 1 0 0 t x X 60 1 0 t y 7 6 7 40 0 1 t z 5 4 5 = 0 0 0 1 1 2 3 X + t x 6 + t y 7 4 + t z 5 1 Translation is matrix multiplication in homogenous coordinates!
Homogenous coordinates 3 a b c t x d e f t y 7 5 g h i t z 0 0 0 1 apple M t 0 T 1 2 X 6 4 1 apple xw 1 3 7 5 = = 2 3 ax + b + c + t x 6dX + e + f + t y 7 4gX + h + i + t 5 z 1 apple Mxw + t 1
Homogenous coordinates 2 3 2 3 X 1 0 0 0 40 1 0 05 6 7 4 5 = 0 0 1 0 1 2 1 0 0 3 0 40 1 0 05 0 0 1 0 2 3 X 4 5 I 2 4 0 X 1 3 5
Perspective projection in homogenous coordinates ~x img = I 0 apple R t 0 T 1 ~x w ~x img = R t ~x w
More about matrix transformations I 0 3 x 4 : Perspective projection apple I t 0 T 1 4 x 4 : Translation apple M t 0 T 4 x 4 : Affine transformation 1 (linear transformation + translation)
More about matrix transformations apple M t 0 T 1 M T M = I Euclidean
More about matrix transformations apple M t 0 T 1 M = sr R T R = I Similarity transformation
More about matrix transformations apple M t 0 T 1 M = 2 3 s x 0 0 4 0 s y 0 5 0 0 s z Anisotropic scaling and translation
More about matrix transformations apple M t 0 T 1 General affine transformation
Matrix transformations in 2D