Constructing a view

The proportion is the assumption

Read the proportions of a rectangle out of a photograph of it and the answer is a function of where the centre of the picture is assumed to be. Sweeping that assumption across the horizon takes one drawn quadrilateral from one part in fourteen to slightly wider than square, every reconstruction a genuine rectangle, and only a fiftieth of the sweep within five per cent of the truth.

Worth reading first: The arc every eye stands on · The principal point is not the centre · The point you have to stand at.

Somebody photographs a rug on a floor and wants to know its proportions. This is a completely ordinary thing to want, it is done constantly, and the machinery for it is four drawn corners and a formula.

The formula needs one number the photograph does not contain, and this essay is about what supplying it wrongly costs.

The proportion is the assumption, not the drawingEvery point of the arc reconstructs a rectangle with right angles to 5.1e-13°, and they run from 0.071 : 1 to 1.120 : 1 — a factor of 15.7. The rectangle that was actually there is 0.667 : 1, and only 2% of the arc gets within five per cent of it. A proportion read off a photograph of a rectangle is a proportion read off the assumption that the centre of the picture is the centre of the frame.012320406080assumed centre of the picture, % of the way between the vanishing pointsreconstructed proportion of the rectanglethe rectangle that was there, 0.667 : 115.7× across the arcevery one a true rectangle
Fig. 1 The recovered proportion of one drawn quadrilateral, as the assumed centre of the picture is walked along the horizon. Every one of these reconstructions has right angles to five parts in ten million million of a degree, and they run from one part in fourteen to slightly wider than square.

What is being assumed

The arc every eye stands on sets it out: four corners give two vanishing points and one equation, and the equation has three unknowns in it. Two of them are the coordinates of the principal point — the foot of the perpendicular from the eye to the picture plane — and everybody assumes it is the middle of the frame.

The assumption is not stupid. A camera whose sensor is centred behind its lens has its principal point at the centre of the frame, and most cameras are built that way to within a per cent or so.

It is also not free, and this site has already priced the ways it fails.

The cost of assuming the principal pointThe two-vanishing-point route to a focal length needs a principal point supplied, and every textbook supplies the middle of the frame. On a shifted or cropped picture that is wrong, and f² = −(v₁ − p)·(v₂ − p) turns the error into a product of two large numbers: 1.6% at 150 px of shift. The three-point recovery does not assume it and has no such error.00.50011.50050100150how far the principal point really is from the middle of the frame (px)error in the focal length, from assuming it is not (%)unshifted: the assumption is truea 44° lens1.55% at 150 px of shift
Fig. 2 And what that does to a recovered focal length. The measured cost is per cents rather than parts per million, which is the difference between an assumption and an identity.

The sweep, and what it is not

The plot above is a sweep of the whole arc, from just inside one vanishing point to just inside the other. That is not a range of plausible assumptions — nobody thinks the centre of the picture is out at a vanishing point — and reading it as an error bar would be a misuse of it.

What it is, is the shape of the dependence. Two things about that shape matter.

It is monotone. Sliding the assumed centre one way always makes the reconstruction longer in one direction. So an error in the assumed centre is a bias in the recovered proportion, with a sign, rather than a scatter — and averaging over many photographs will not remove it if they share a camera.

And its slope is not uniform. The curve is shallow in the middle and steep near the ends, so how much a given error in the assumed centre costs depends entirely on where along the arc the picture falls.

The proportion is the assumption, not the drawingEvery point of the arc reconstructs a rectangle with right angles to 6.1e-13°, and they run from 0.417 : 1 to 6.531 : 1 — a factor of 15.7. The rectangle that was actually there is 0.667 : 1, and only 2% of the arc gets within five per cent of it. A proportion read off a photograph of a rectangle is a proportion read off the assumption that the centre of the picture is the centre of the frame.024620406080assumed centre of the picture, % of the way between the vanishing pointsreconstructed proportion of the rectanglethe rectangle that was there, 0.667 : 115.7× across the arcevery one a true rectangle
Fig. 3 The same sweep for a rectangle placed obliquely in the frame. The curve is steeper, so the same uncertainty about the centre buys a wider range of answers.
The proportion is the assumption, not the drawingEvery point of the arc reconstructs a rectangle with right angles to 1.7e-12°, and they run from 0.036 : 1 to 0.561 : 1 — a factor of 15.7. The rectangle that was actually there is 0.667 : 1, and only 0% of the arc gets within five per cent of it. A proportion read off a photograph of a rectangle is a proportion read off the assumption that the centre of the picture is the centre of the frame.00.2000.4000.60020406080assumed centre of the picture, % of the way between the vanishing pointsreconstructed proportion of the rectangle15.7× across the arcevery one a true rectangle
Fig. 4 And for one placed nearly square-on. Shallower, and better conditioned, for the identical camera.

The realistic version

Restricted to the range a real camera’s principal point actually occupies — a few per cent of the frame width off centre, which covers an ordinary lens, a modest shift and a crop — the numbers come down to something a person would care about rather than something that makes the exercise look hopeless.

A few per cent of the frame width, on the sweep above, moves the recovered proportion by several per cent. Which means: a proportion read off a photograph of a rectangle is good to a few per cent and not better, unless the principal point has been established some other way.

Two rectangles need no assumption at all

The assumption is unavoidable with one rectangle and avoidable with two, and the construction is a pair of compasses.

The arc is the circle having the rectangle’s two vanishing points as a diameter: the locus of eyes, folded into the picture, that see those two directions at a right angle. A second rectangle lying at a different angle on the same floor has its own two vanishing points on the same horizon, and its own circle.

The camera’s eye is on both. So it is at one of the two points where the circles cross — and the one above the horizon is the station.

Counting confirms it. For a level camera the principal point lies on the horizon, so there are two unknowns: where along the horizon, and the focal length. Each rectangle supplies the one equation f2=−(v1−p)⋅(v2−p)f^{2} = -(\mathbf{v}_1 - \mathbf{p})\cdot(\mathbf{v}_2 - \mathbf{p}), so two rectangles are exactly enough, and the intersection of two circles is that pair of equations solved with a straightedge and compasses instead of algebra. A third rectangle over-determines it and gives a residual, which is a check rather than an improvement.

That changes what a photograph of a room is worth. A rug at one angle and a table at another; the floor lines of two walls meeting at a corner; a door and a window in the same wall. Any two rectangles whose edge directions differ, and the principal point stops being assumed. The photograph calibrates itself, which is the same service three perpendicular directions perform in a scene with a box in it, done here with two flat objects and no box at all.

The conditioning is visible in the construction, which is its own recommendation. Two circles cross sharply when they cross at a large angle and poorly when they are nearly tangent — and they are nearly tangent when the two rectangles lie at nearly the same angle on the floor, because then their vanishing points nearly coincide and their diameters nearly do too. So:

Two rectangles turned well apart give a sharp station; two nearly aligned give almost nothing. Two parallel rugs are one rectangle, which is the degenerate case arrived at continuously — the second circle collapses onto the first and the intersection becomes the whole arc again.

That is the same shape of statement perpendicular is a pairing makes about which pairs of directions carry a constraint, and it converts the essay’s finding into a piece of practical advice. Faced with a photograph and a proportion to recover, do not improve the assumption about the centre — find a second rectangle at a different angle, and the assumption is not needed. It is the cheapest of the closures this collection prices, because unlike a scale bar or a known height it requires nothing to have been brought to the scene, and it is one of the five facts that close the same gap with the peculiarity that the photograph usually already contains it.

The residual limitation is worth stating so the claim is not read as larger than it is. Two rectangles fix the eye for a level camera. A tilted one puts the principal point off the horizon and restores a third unknown, so three rectangles are needed — or two rectangles and the vertical vanishing point, which a tilted photograph of a room supplies for free. And every one of these routes assumes the drawn quadrilaterals really are images of rectangles, which is the assumption the next rung tests rather than one it can remove.

One more consequence, because it changes what “a few per cent” means. The single-rectangle error is a bias shared by every rectangle in a photograph taken with the same camera, since they all inherit the same wrong principal point. So a reader comparing two rugs in one picture gets their ratio far better than either proportion — the common factor divides out — while a reader comparing a rug in one photograph with a rug in another gets neither the proportions nor the comparison, because the two cameras’ principal points are independently wrong. Within one photograph the assumption is nearly free; across two it is the whole error, which is the opposite of how a per-cent figure is normally read.

That is a useful number and it is worth putting beside the ones this site has measured elsewhere. How wrong a measurement from one picture can be prices the height-from-a-photograph route the same way, and finds the same shape of answer: exact geometry, an assumption in the middle of it, and an error set by the assumption rather than by the arithmetic.

A 5.6 m object, measured off an uncorrected frameOn a pinhole picture the horizon-fraction recovery returns 5.6 m exactly. Through a lens with k₁ = -0.24 it returns 5.48 m — 2.15% out. A 2.2 m object at the same spot on the same lens comes back 0.14% out, because what costs is the radius the three marks span, not where in the frame they are.5.405.505.60-0.400-0.2000k₁ of the lens the photograph was taken withheight recovered from the photograph (m)the true 5.6 m5.48 m5.6 m tall, 11 m away, on a level camera2.15% out — against 0.14% for a 2.2 m object
Fig. 5 The height measurement’s own version. Every route from a single picture to a length has one of these somewhere in it.

Why this is not an argument against the method

There is a reading of the sweep that would be wrong, and it is worth heading off.

The plot runs over a factor of nearly sixteen, which looks catastrophic. It is not, because the sweep covers the whole arc and the arc’s ends are stations nobody would propose. At one end the eye is nearly on the horizon, which is a camera looking exactly along one of the rectangle’s edges from ground level; at the other it is nearly on the other vanishing point. Neither is a photograph anybody takes, and the reconstructions there are extreme because the stations are.

Every eye that could have drawn it lies on one arcThe four corners of a rectangle on the floor, drawn. Its two vanishing points are the ends of the arc, and the eye — folded flat into the picture about the horizon — has to see them at a right angle, so it lies on the circle having them as a diameter. Sliding the assumed centre of the picture along the horizon slides the station round the arc: at 90% of the way between the two vanishing points the focal length comes out 677.9 px and the rectangle is reconstructed 0.8489 wide for every one deep, with its corners at right angles to 5.7e-14°. The camera that actually drew it is the mark on the arc at 812.8 px. Nothing in the four corners chooses between them.where the camera wasassumed centre 90% alongfocal 677.9 px · 0.849 : 1
Fig. 6 A station near one end of the arc. The focal length is short, the picture it corresponds to is enormously wide, and the reconstruction is correspondingly stretched.

What the plot is for is the derivative at the middle, not the extremes at the ends. That is why the section above restricts to the range a real principal point occupies before quoting anything, and it is why the honest headline of this essay is “a few per cent” rather than “a factor of sixteen”.

What actually fixes it

Four things, in rough order of how likely a photograph is to contain them.

A second rectangle on the same plane, at a different angle. Two pairs of perpendicular directions determine the involution on the horizon, which determines both the focal length and where the centre is along it — with nothing assumed.

A vertical, which turns the problem into the three-direction recovery and over-determines the camera.

A known proportion somewhere in the scene — one square tile, one sheet of paper — which supplies the missing number directly.

Or a calibrated camera, which is what the whole business of camera calibration exists for and is the only one of the four that is a fact about the equipment rather than about the picture.

Which way the bias runs

A bias with a sign can be traced, and this one can be described without any arithmetic.

Assume the centre of the picture is too far toward one of the two vanishing points. The perpendicular from it meets the arc nearer that end, which means the station is being placed nearer that vanishing point — that is, the camera is being taken to have been more nearly along one of the rectangle’s two edge directions than it really was.

A camera more nearly along a direction sees that direction more foreshortened. So the reconstruction has to make the rectangle longer in that direction to account for the drawn extent, and the recovered proportion moves that way.

Every eye that could have drawn it lies on one arcThe four corners of a rectangle on the floor, drawn. Its two vanishing points are the ends of the arc, and the eye — folded flat into the picture about the horizon — has to see them at a right angle, so it lies on the circle having them as a diameter. Sliding the assumed centre of the picture along the horizon slides the station round the arc: at 34% of the way between the two vanishing points the focal length comes out 1070.5 px and the rectangle is reconstructed 0.2031 wide for every one deep, with its corners at right angles to 4.3e-14°. The camera that actually drew it is the mark on the arc at 812.8 px. Nothing in the four corners chooses between them.where the camera wasassumed centre 34% alongfocal 1070.5 px · 0.203 : 1
Fig. 7 The assumed centre moved toward one vanishing point. The station slides that way round the arc and the reconstruction stretches along the corresponding edge direction.

That gives the practical rule. An error in the assumed centre stretches the reconstructed rectangle along whichever edge direction the error moves toward, and a photographer who knows their lens is shifted knows which way their answers are wrong before computing anything.

The part that is easy to get backwards

The reconstruction is a genuine rectangle at every station, and that is worth dwelling on because it removes the obvious sanity check.

A reader who suspected the assumed centre was wrong might reasonably look for a symptom: corners that come out not-quite-square, edges that do not quite match. There is none. The focal length is chosen at each station precisely so that the two directions are perpendicular, so the reconstruction has right angles by construction — to the arithmetic floor, across the entire sweep.

Every eye that could have drawn it lies on one arcThe four corners of a rectangle on the floor, drawn. Its two vanishing points are the ends of the arc, and the eye — folded flat into the picture about the horizon — has to see them at a right angle, so it lies on the circle having them as a diameter. Sliding the assumed centre of the picture along the horizon slides the station round the arc: at 14% of the way between the two vanishing points the focal length comes out 784.1 px and the rectangle is reconstructed 0.1142 wide for every one deep, with its corners at right angles to 4.0e-13°. The camera that actually drew it is the mark on the arc at 812.8 px. Nothing in the four corners chooses between them.where the camera wasassumed centre 14% alongfocal 784.1 px · 0.114 : 1
Fig. 8 A station well round the arc. The reconstruction from here is a rectangle a fifth as wide as it is deep, and its corners are right angles to a tenth of a millionth of a millionth of a degree.

So the wrongness is invisible in the reconstructed object. It shows up only against something outside the reconstruction — a second rectangle, a known length, a calibrated camera — which is the general shape of every under-determined problem and is why the arc had to be found before the sensitivity could be quoted.

What a crop does, which is not obvious

A crop moves the principal point relative to the frame without moving anything in the world, and the arithmetic notices.

Photograph a rug, crop the picture off-centre, and hand the crop to somebody. The rectangle’s four corners are unchanged in the world and their positions relative to the frame have moved. Assume the centre of the frame is the centre of the picture and the assumption is now wrong by exactly the crop.

That is worth flagging because a crop is invisible. Nothing in a cropped photograph says it was cropped, whereas a shifted lens leaves a signature — the verticals stay parallel while the composition is off-centre — and a tilt leaves a bigger one.

The rule that follows is a small piece of practice: measure from the original frame, not from a crop, and if only a crop is available, say so alongside the answer.

What this does not say

It says nothing about lens distortion. Every corner here is exactly projected; a real photograph’s corners have been moved by the lens before anything is fitted, and the two errors compound.

It says nothing about the four corners being read accurately. Every position here is exact to the last bit, and a real one is a click on a screen.

And it does not say the assumption is a bad one. It says the assumption is doing more work than it looks like it is doing, and that the answer should be quoted with it stated. A proportion reported as “1.62 : 1” is a claim; the same number reported as “1.62 : 1, assuming the principal point is the centre of the frame” is a measurement, and the difference costs eleven words.

Where this leaves the ordinary case

None of the above says that reading a rectangle out of a photograph is a bad idea. It is a good idea and it is what a single view is for. What the sweep supplies is the sentence that has to go with the answer.

Three practical statements come out of it, and they are all that is needed.

Report the assumption. A proportion recovered from four corners has a principal point in it, and naming it costs a clause.

Prefer the composition that is well conditioned. A rectangle near the middle of the frame, seen fairly square-on, sits at the shallow part of the curve. One at the edge, seen obliquely, sits at the steep part. That is a choice a photographer makes before pressing anything, and it is worth more than any amount of care afterwards.

And take the second rectangle when it is free. A floor with two differently oriented rugs on it, a room with two tables at different angles, a paving pattern that changes direction — any of them closes the family for nothing, and the resulting measurement has no assumption in it at all.

What a second photograph would do

The obvious suggestion, when one photograph is short of information, is to take another. It is worth saying what that does and does not buy here.

Two photographs of the same rectangle from two places give two arcs — but they are arcs in two different pictures, and they cannot simply be crossed. What two views do supply is the relative pose of the two cameras and the shape of the scene, up to scale, and that is enough to determine the rectangle’s proportion without any assumption about the centre of either picture.

So the second photograph is a stronger instrument than the second rectangle and a much larger piece of work. The second rectangle is free — it is already in the picture or it is not — and it closes exactly this gap; the second photograph needs correspondences and a pose recovery and gives back the whole scene.

Which is the right trade depends on what is wanted. For a proportion, the second rectangle. For a room, the second view.

The transferable form

When a measurement needs a quantity the data does not contain, the honest output is not a number but a function of that quantity — and its slope, not its range, is what the reader needs.

The whole sweep is not an error bar and it would be dishonest to present it as one. Its slope, at the point the assumption lands on, is the thing: it converts a per cent of uncertainty about the centre of a picture into a per cent of uncertainty about the answer, and it is different for every composition.

This site keeps arriving at the same shape. Depth is a reciprocal turns a fixed reading error into an interval that is not symmetric; a shadow across a second object has an amplification of one over a sine with no upper bound; and here a per cent of the frame becomes several per cent of the answer. Every one of them is exact geometry with a conditioning number in front of it, and every one of them is worthless quoted as a single figure.

What links here

Computed from the collection, not written here: the essays that point at this one.

Shares its objects with

Essays that name at least two of the same things, and that neither author linked.

Named objects

A flat tag is an object no other essay names yet.

Camera calibrationConditioningCrop factorDemonstrationDepicted rectangleerror propagationFocal recoveryFree parameterLens shiftPrincipal pointStation point