TL;DR

  1. Linear perspective: a 3D point is projected by intersecting the line from the point to the viewpoint with a picture plane. By similar triangles : twice as far means half as big. The division by makes the projection non-linear.
  2. A bare sensor gives a blurred image. A pinhole gives a sharp linear perspective but is too dark. A lens gathers more light and still gives a linear perspective, but only one plane is in focus. Gaussian lens formula: .
  3. Forward projection goes through four coordinate systems: world → camera → film → pixel. Only camera → film loses information (depth).
  4. Homogeneous coordinates turn the projection into a matrix product. The whole chain is one matrix .
  5. Extrinsics (where the camera is) with . Intrinsics (how the camera is built).
  6. Orthographic projection drops . It is a good model for telephoto and telecentric lenses.

The lecture has two parts: an introduction to image formation, then the mathematical formalization with the projection matrix.

Part 1: Image Formation, Introduction

Why Image Formation?

Slides 3-5

Computer vision goal: predict the 3D world from a single image. For example, recover the 3D mesh of a human (pose and shape) from a photo. This means we have to invert the image formation process.

Computer graphics goal: the reverse problem. Given controls for shape, pose and clothing, generate realistic images of humans.

Slide 3: image → 3D human
Slide 3: image → 3D human

The boundaries between the two fields are more and more blurred: we often need to solve both problems at the same time. For both, we first need to understand image formation: the physical process that captures the light emitted by a 3D scene and produces an image.

The Laws of Perspective

Slides 6-11

Common assumptions:

  1. Light leaving an object travels in straight lines.
  2. These lines converge to a point at the eye.

Natural perspective (Euclid, 3rd c. B.C.)

More distant objects subtend smaller visual angles. If an object comes closer to the eye, the angle becomes larger than .

Roman wall paintings (Pompeii, Herculaneum) follow natural perspective: distant objects are smaller, but the proportions are not quite right and the paintings look flat. Natural perspective is not enough, they need linear perspective.

Linear perspective (Filippo Brunelleschi, 1413)

A perspective image is formed by the intersection of the lines of sight with a picture plane (the canvas).

Natural perspective measures angles, linear perspective measures heights on the picture plane
Slide 10: natural perspective (angles) vs. linear perspective (heights on the picture plane).

In linear perspective, the two black dots of the object are projected by intersecting the straight line from each 3D point to the observer with the picture plane. When the object comes closer, its height in the picture gets larger (). But the ratio is different from natural perspective:

These are two different perspectives.

Projection onto the picture plane

Slide 11

Whiteboard derivation of y = h f / z with similar triangles
Slide 11: projecting a point P onto the picture plane with similar triangles.

We want to project a point at height and depth onto the picture plane, i.e. find its image height . The picture plane is at distance from the viewpoint (the focal length). By similar triangles:

Perspective projection

Intuition

The mapping requires a division by , so it is a non-linear projection. The size of an object in a photograph is inversely proportional to its distance from the camera: if I am twice as far away, I appear half as big.

Exam relevance

This formula is the one to know best (“pinhole camera, lecture 2 slide 11”). The calculation tasks in the exam used it in both directions. See Worked Examples.

Vanishing Points

Slides 12-18

In linear perspective, straight lines remain straight. But parallel lines don’t remain parallel: objects appear smaller the further away they are, so parallel lines converge to a vanishing point.

1-point, 2-point and 3-point perspective drawings
Slide 12: 1-point, 2-point and 3-point perspective.

How many vanishing points can there be in a perspective drawing?

Should the distant ends of a long facade be drawn smaller than its center in a perspective drawing?

Panorama of a long facade
Slide 15: the long facade question.

Why does this perspective drawing of columns look distorted?

Columns drawn in linear perspective appear wider at the sides
Slide 17: the columns at the sides look wider, but the drawing is correct.

Recap (Slide 18)

  • Natural perspective: the visual angle subtended by a feature in the world.
  • Linear perspective: intersections of lines of sight with a picture plane. The correct way to make a drawing on a flat surface.
  • Vanishing points: one per direction of line in the scene. Lines parallel to the picture plane do not converge.

From Pinhole to Lens

Slides 19-27

A camera like the Nikon F4 (SLR) contains a lot of glass: the lenses. Do cameras need lenses? Can we just put a sensor?

Why not use sensors without optics?

Slide 20

Every location on the sensor would receive the integral of rays coming from many different places in the scene. Nearby image locations would get almost the same color, and the whole image would be blurred.

Rays from all scene points hit every sensor location
Slide 20: without optics, every sensor point sees every scene point.

Pinhole camera (camera obscura)

Slides 21-22

Since ages it is known that you can make a hole in a wall and put a sensor (or a white wall) on the other side. This pinhole camera or camera obscura gives an image with linear perspective, with the viewpoint at the pinhole. Everything is in focus. The image is inverted: a ray from the top of the scene lands at the bottom of the image and vice versa. Tilting the picture plane changes the number and location of the vanishing points.

Camera obscura
Slide 21: camera obscura
Camera obscura and Dürer's glass
Slide 22: camera obscura and Dürer's glass

In the pinhole model, the image is produced behind the pinhole. A completely equivalent model puts the image plane in front of the pinhole (Dürer’s glass). Both compute 2D planar geometric projections (along straight lines through a point onto a plane). The images differ only in scale and a reflection around the origin. The front model makes the similar-triangle math easier, so we use it from now on.

Effect of pinhole size

Slides 23-24

Problem: a pinhole does not let enough light through. If we make it larger, all rays that arrive at one pixel form a cone. Every pixel becomes the integral over a region of the scene, so the image looks blurry, even for small pinholes. That is why real cameras don’t use pinholes.

Photos with small and larger pinhole
Slide 23: small pinhole (top) vs. larger pinhole (bottom).

Replacing the pinhole with a lens

Slides 25-27

A lens takes all the rays leaving one point and brings them back to a single point. It still gives a linear perspective:

  • A lens replaces the pinhole, and the film or digital sensor becomes the picture plane.
  • The effective linear-perspective rays are the straight rays through the middle of the lens. So the effective pinhole is at the center of the lens.
  • Rotating the camera (and lens) around the lens center adds or removes vanishing points.
Photo with small pinhole vs photo with lens
Slide 25: pinhole (top) vs. lens (bottom).

Geometrical optics: two principles

  1. Parallel rays converge to a point located at the focal length from the lens.
  2. Rays going through the center of the lens are not deviated, hence the same perspective as a pinhole.

Pretty much everything else can be derived from these two.

Parallel rays converge at f, rays through the center pass straight
Slide 27: the two principles of geometrical optics.

The Gaussian Lens Formula

Slides 28-35

Gauss’s ray tracing construction

Slide 28

A consequence of the two principles: points on a plane parallel to the lens are focused to points on another plane parallel to the lens. Take the top ray from an object point: it is bent to pass through the focal point and hits the image plane at some height. The ray through the front focal point is bent to leave the lens parallel and hits exactly the same point.

Gauss's ray tracing construction
Slide 28: Gauss's ray tracing construction.

Changing the focus distance

Slides 29, 33

The focal length is where parallel rays converge, and parallel rays come from objects at infinity. If we move the sensor relative to the focal point, rays from objects at a finite distance are focused into a single point. So objects at a fixed distance get in focus.

  • To focus on objects at different distances, move the sensor relative to the lens.
  • In a handheld camera, one actually moves the lens, not the sensor.
  • By convention, the focus distance is on the object side of the lens.

Derivation

Slides 30-32

Conventions: positive is rightward, positive is leftward, positive is upward. is the object distance, the image (sensor) distance, the object height, the image height.

Similar triangles for the Gaussian lens formula
Slide 32: the two pairs of similar triangles.

Gaussian lens formula

For a lens with fixed focal length , it tells us how far the sensor has to be from the lens to focus an object at distance (or how much to change the focal length).

Pinhole camera model vs. lens camera model

Slides 34-35

Pinhole model y = f h / z vs lens model y = s_i h / z
Slide 34: in the lens model, the image size depends on the sensor distance s_i.
Pinhole camera modelLens camera model
Image height, with
Meaning of distance from the pinhole to the image planea physical property of the lens: the distance at which parallel rays converge. Does not depend on the sensor position
Linear perspective set by, the distance from sensor to lens

From the lens formula (with object depth ): as the depth goes to infinity, , we get .

Intuition

A lens with focal length is equivalent to a pinhole at distance . This is why in computer vision we typically work with the pinhole camera model and don’t think about lenses, unless we need to undistort images.

Two meanings of f

In the pinhole model, is the sensor distance. In the lens model, is a property of the lens and the perspective is set by .

Focal Length, Field of View and Viewpoint

Slides 36-42

Changing the focal length

Slide 36

If the sensor size is constant, a larger focal length gives a smaller field of view. The field of view is two times the angle of the half triangle:

Field of view

Larger focal length → smaller field of view. That is why the field of view gets narrower when we zoom.

Field of view shrinks with larger focal length
Slide 36: field of view and focal length.

Changing the sensor size

Slide 37

  • If the sensor is smaller, the field of view is smaller too.
  • Smaller sensors either have fewer pixels, or smaller pixels, which are noisier.

Changing the focal length vs. changing the viewpoint

Slides 38-40

  • Changing the focal length lets us move back from a subject while keeping its size in the image.
  • But moving back changes the perspective relationships. In the photos below, the front subject has the same size in all three. With the telephoto lens (camera moved back), the subject in the back appears bigger relative to the front subject: the focal length is very large, so the difference in depth matters less for the difference in image size.
Wide-angle vs telephoto and moved back
Slide 38: wide-angle (left) vs. telephoto and moved back (right).

Moving forward while shortening the focal length keeps objects at one depth the same size. In cinematography this is the dolly-zoom or “Vertigo effect”, after Alfred Hitchcock’s movie.

Dolly zoom in Vertigo
Slide 40: the dolly-zoom.

Effect of focal length on portraits

Slide 41

The standard “portrait lens” is 85 mm. For faces this effect is very important. Remember the division by depth: close to the camera, depth differences matter a lot, so we get strong perspective effects (a big nose with a wide-angle lens). Far away, a small depth difference (nose vs. eyes) is negligible.

Portraits with wide angle, standard and telephoto lens
Slide 41: wide angle, standard and telephoto portraits.

Recap (Slide 42)

  • Pinhole cameras compute correct linear perspectives, but they are dark.
  • Lenses gather more light, but only one plane of the scene is in focus. The distance from the lens to this plane is the focus distance. We change what is in focus by moving the sensor or the lens.
  • The focal length determines the field of view (from wide angle to telephoto), and the field of view depends on the sensor size.

Part 2: Image Formation, Projection Matrix

The goal now is to express the image formation process using a single projection matrix.

Imaging Geometry: Four Coordinate Systems

Slides 43-51

  • An object of interest is given in a world coordinate system , which can be different from the camera coordinate system.
  • The camera coordinate system : by convention the axis is the optic axis of the camera. The image plane is located units out along the optic axis ( is the focal length). We use the equivalent model with the image plane in front of the camera center.
  • Forward projection onto the image plane: the 3D point is projected to the 2D film coordinates . These are still metric units (e.g. centimeters).
  • The image then gets digitized into pixel coordinates . Units are pixels.
Camera, image (film), world and pixel coordinates
Slide 48: the four coordinate systems.
flowchart LR
  W["World coords<br/>(U, V, W)"] -- "rigid transformation<br/>M_ext" --> C["Camera coords<br/>(X, Y, Z)"]
  C -- "perspective projection<br/>M_proj" --> F["Film coords<br/>(x, y)"]
  F -- "affine transformation<br/>M_aff" --> P["Pixel coords<br/>(u, v)"]

So there are three transformations:

  1. World → camera: a rigid transformation (rotation + translation).
  2. Camera → film: the 3D-to-2D perspective projection.
  3. Film → pixel: depends on the sensor hardware (pixel size, principal point).

We want to describe this sequence by one matrix equation. A matrix means a linear mapping, which the projection is not. We will use a trick (homogeneous coordinates) to write it as a linear mapping anyway.

Forward vs. backward projection

Much of computer vision is about backward projection: deriving equations that recover the 3D scene structure from images (via stereo or motion, by triangulation, or with learned priors). Structure from motion follows in Lecture 3. But first we have to understand the forward projection, which is the computer graphics problem.

Backward projection from pixel to world coordinates
Slide 50: backward projection.

Trap

Only camera → film loses information: the division by throws away the depth. World → camera and film → pixel are invertible.

Basic Perspective Projection

Slides 52-55

We start in the middle of the chain: camera coordinates to film coordinates. A scene point is projected to the image point by linear perspective. For the direction: is to as is to . The direction works exactly the same way.

Similar triangles for x
Slide 53: similar triangles for x
Similar triangles for y
Slide 54: similar triangles for y

Perspective projection equations

How do we write this as a matrix equation? The division by makes the mapping non-linear, so we need homogeneous coordinates.

Why no matrix works in normal coordinates

Scale the 3D point by : . The image does not change. A linear map would scale the result by .

Homogeneous Coordinates

Slides 56-57

Homogeneous coordinates

Represent a 2D point by a 3D point by adding a “fictitious” third coordinate. By convention, the 2D point is recovered as

Scaling does not change the point:

( can be negative as well as positive.)

With this change of coordinates, the perspective projection becomes linear and can be written as a matrix:

Perspective matrix equation (in camera coordinates)

Dividing by gives back and .

Perspective matrix equation
Slide 57: the perspective matrix equation.

Trap

The non-linearity is not gone, it is moved out of the matrix: the division happens at the end, when we go back from homogeneous to normal coordinates.

World to Camera: Extrinsic Parameters

Slides 58-71

The first transformation, from world to camera coordinates, is a rigid transformation (rotation + translation) between the world and camera coordinate systems. It is a simple change of coordinates.

To express a point in camera coordinates:

  1. Translate by to align the origins ( is the camera center in world coordinates).
  2. Rotate by to align the axes.
World to camera transformation: translate by -C, rotate by R
Slide 59: world to camera transformation.

World to camera

In homogeneous coordinates:

Columns of R

The columns of are the axes of the source coordinate frame expressed in the target coordinate frame (more on rotations in Lecture 2.2). So is the world axis in camera coordinates. If camera and world frames are aligned, this column is : 1 times the axis plus 0 times the and axes.

Example: simple stereo system

Slides 61-64

The world axes are aligned with the left camera. The left camera is at the world origin , the right camera at , both with axes aligned with the world axes.

Simple stereo system with two cameras
Slide 61: simple stereo system.
  • Left camera: rotation and translation are both the identity, so the transformation is the identity.
  • Right camera: the axes are aligned, so the rotation is the identity, but the origin is translated by (the camera center in world coordinates is ).

Simple stereo projection equations

This setup comes back in Lecture 4 (disparity ).

Figuring out rotations

Slides 65-69

When thinking about rotations, forget about the translation: the rotation is a property of the axes alone. The equation says how vectors in the world coordinate system (including the coordinate axes) get transformed into the camera coordinate system.

Method 1: if we know that the world axis corresponds to the camera axis , then

and we can immediately write down the first column of . Likewise with the world and axes for the other columns.

Method 2: sometimes it is easier to specify what the camera , or axis is in world coordinates. Then rearrange (R is orthogonal):

Now the rows of are the camera axes in world coordinates.

First column of R from the world x axis
Slide 66: first column of R
External parameters written as R and T
Slide 70: external parameters as R, T

External parameters as R, T

Slide 70

Extrinsic parameters

T is not the camera position

is the camera center in world coordinates. . Only if is .

Summary so far (Slide 71): we know how to transform 3D world points into camera coordinates, and then do a perspective projection to get 2D points in the film plane. Next: pixel coordinates.

Film to Pixel: Intrinsic Parameters

Slides 72-80

The film-to-pixel step is an affine transformation. The intrinsic parameters describe the coordinate transformation between film coordinates (the projected image) and the pixel array. They depend on the hardware of the sensor: how large the pixels are, what shape they have, and so on. For film cameras this is the scanning/digitization, for CCD cameras the grid of photosensors.

Offsets: the principal point

Slide 74

The film plane has its origin in the center. The pixel array has its origin in the top left corner ( = column, = row). In principle the center of the sensor is the principal point, so we translate by :

and are called the image center or principal point.

Film plane with origin in the center, pixel array with origin in the corner
Slide 74: offsets from film plane to pixel array.

Flipped axes

Slide 75

Sometimes one or more axes are flipped, e.g. the film and correspond to and :

Tip

This is a common bug: if your own renderer shows a flipped or cropped image, it is usually a problem with the axes.

Scales

Slides 76-77

The sensor captures an analog signal that is resampled into a pixel array. This discretization step decides how many rows and columns the image has (the resolution). At the same scanning resolution, a bigger sensor gives a higher resolution. This gives a scale from film to pixel coordinates, possibly different in and :

Effective scales

are the pixel sizes. Since the scale factors can differ, pixels are not necessarily square. The aspect ratio is .

Film scanning and CCD resampling into a pixel array
Slide 76: from film or CCD to the pixel array.

Perspective projection matrix

Slide 78

Adding the intrinsic parameters into the perspective projection matrix gives the intrinsic camera matrix. It depends on the hardware of the camera, not on where the camera is relative to the world.

Intrinsic matrix

To verify: and .

Note (Slide 79): sometimes image and camera coordinate systems have opposite orientations (the book does it this way). Then and the matrix gets and on the diagonal.

Note 2 (Slide 80): we can also think of the conversion as two separate transformations: a projection and a 2D affine transformation from film coordinates to pixel coordinates :

Summary: Forward Projection

Slide 81

Forward projection: M_ext, M_proj, M_aff combine to M_int M_ext and one matrix M
Slide 81: the chain collapses into one 3x4 matrix M.

Full projection

The tilde means homogeneous coordinates. : where the camera is (, ). : how the camera is built (, , , , ).

This perspective camera model is the most commonly used camera projection model in computer vision and graphics.

Projection Models: Orthographic Projection

Slides 82-85

Sometimes an even simpler model is useful: orthographic projection, which completely ignores the linear perspective effects. It is a good model for telecentric lenses and telephoto cameras: the object is far away and the zoom is very large, so perspective effects can be ignored.

Orthographic vs perspective projection with example lenses
Slide 82: orthographic projection (telecentric, telephoto lenses) vs. perspective projection.

With increasing focal length and distance from the camera, the perspective effects disappear: perspective → weak perspective → orthographic.

Perspective to orthographic with increasing focal length
Slide 83: perspective effects disappear with increasing focal length / distance.

Orthographic projection

Projection of a 3D point to pixel coordinates :

  • The and axes of the camera and image coordinate systems are shared.
  • Light rays are parallel to the axis of the camera coordinate system.
  • During projection, the coordinate is dropped, and stay the same: .

Scaled orthographic projection

In practice, world coordinates (e.g. meters) must be scaled to fit onto the image sensor (pixels):

The unit of is px/m or px/mm.

Under orthography, structure and motion can be estimated simultaneously with factorization methods (e.g. via singular value decomposition). This is the Tomasi-Kanade factorization from Lecture 1.

Perspective projectionOrthographic projection
Equation (scaled: )
Linear?no, division by (needs homogeneous coordinates)yes
Depth effectsfar objects smaller, vanishing pointsnone
Good model fornormal camerastelecentric and telephoto lenses

Worked Examples

These are practice examples in the style of the calculation tasks from the exam. The numbers are made up.

Exam relevance

  • Calculation task from lectures 1-2: in both directions. Scenario from the exam: two people of different height, camera with a given focal length at a given distance: how far must the camera move back so both appear equally tall? Second part: compute from , and .
  • A third calculation part probably involved the principal point and depth (not fully remembered).
  • The four coordinate systems and which step loses information.
  • Why homogeneous coordinates are needed.
  • with .
  • The intrinsic matrix and what each parameter means.
  • Perspective vs. orthographic projection.

Self-Test

What is the difference between natural and linear perspective?

Derive the perspective projection equation and state its consequence.

Why is perspective projection not linear?

Why don't we use a pinhole camera in practice, and what does a lens change?

State the Gaussian lens formula. What does it give as ?

How does the field of view depend on the focal length?

Name the four coordinate systems and the transformation between each pair. Which one is not invertible?

What are homogeneous coordinates and why do we need them here?

What do the columns of mean in ?

Is the camera position?

Write down the intrinsic matrix and explain its parameters.

When is orthographic projection a good model, and how does it differ from perspective projection?