The rectangle behind the lens

A close picture carries its own distance

A 50 mm lens focused at one metre stands 2.632 mm beyond its focal length, and a picture records where the lens stood. Recover that from two vanishing points, put in the engraved focal length, and the focus distance comes back — to 0.7 per cent at 1 m, 3.7 at 5 m, and as an interval 28 per cent wide at 30 m. A single picture has given a scale. What it has given is where the lens was focused, and the subject can be anywhere in a sharp band two to fifteen times wider.

Worth reading first: A focal length is not an angle · The eye is a place, not a point.

Focusing is a zoom found that a lens focused close is a different camera from the one engraved on its barrel. A 50 mm lens that focuses by moving as a whole stands 52.63 mm from the sensor when it is focused at one metre and 55.56 mm at half a metre, and the camera recovered from its picture reports those distances rather than fifty. That essay treated the gap as a hazard: a measurement pipeline that believes the engraving starts from the wrong camera.

The same gap is also information. How far the lens stands beyond its focal length depends on nothing but the focal length and the distance it was focused at. A picture that reveals where the lens stood therefore reveals, with the engraving, how far away the lens was focused — and a distance is exactly what the one thing a single view cannot give said a single picture has no way to supply.

Whether it actually does, and how well, is a measurement.

A focus distance read from a picture, and how its precision falls awayA 50 mm unit-focusing lens focused at 0.3 to 30 m. The picture's principal distance is recovered from two vanishing points, and with the engraved focal length it gives back the distance the lens was focused at — exactly, from exact vanishing points. With each vanishing point read to ±0.25 px, the recovered distance can be out by up to 0.7 % at 1 m, 3.7 % at 5 m and 28 % at 30 m. At ±1 px it is 2.7 % at 1 m and 755 % at 30 m.0.30.71.537200.11101001000distance the lens is focused at (m, log scale)how far the recovered distance can be out (% , log scale)vanishing points ±0.25 pxvanishing points ±1 px±0.25 px: 0.7 % at 1 m → 28 % at 30 m50 mm lens
Fig. 1 A 50 mm unit-focusing lens focused at 0.3 to 30 m, its focus distance recovered from two vanishing points and the engraved focal length. It comes back exactly from exact vanishing points. With each read to ±0.25 px it can be out by up to 0.7 % at 1 m, 3.7 % at 5 m and 28 % at 30 m; at ±1 px, by 2.7 % at 1 m and 755 % at 30 m.

Two numbers and one equation

The recovery has three steps and none of them is new.

First, the principal distance. Recovering the camera reads it from the vanishing points of two horizontal directions at right angles: it is the square root of minus the product of their offsets from the principal point. For a lens focused close that returns vv, the distance the lens stands from the sensor, not the engraved ff.

Second, the engraving, which is a fact about the lens rather than the picture.

Third, the thin-lens equation 1/u+1/v=1/f1/u + 1/v = 1/f, turned round:

u=fvvf.u = \frac{f\,v}{v - f}.

With exact vanishing points the three steps give back the focus distance exactly, at every distance from 30 cm to 30 m; the figure checks it to a part in a billion. And a distance brings a scale with it. The magnification at focus is v/u=f/(uf)v/u = f/(u - f) — 0.0526 at one metre for the 50 mm lens — so anything lying at the focus distance has a real size equal to its size on the sensor divided by that number. A face 7.9 mm tall on the sensor, at one metre, is 150 mm tall.

That is not a contradiction of the single view’s ambiguity, and it is worth being exact about why. A pinhole picture of a scene is identical to the picture of the same scene scaled up and moved proportionally further away; nothing in the picture separates them. A lens breaks the tie only because the photographer also knows a length that belongs to the camera — the focal length — and because the principal distance, which the picture does reveal, is tied to the focus distance by that length. The picture alone still gives no scale. The picture and the engraving together do, in the same way that a height from one photograph needs one known height in the scene: one length from outside, this time supplied by the lens instead of the room.

What the distance is read from

The equation reads the distance from vfv - f, the extension, and how precisely a distance comes back depends on how that extension compares with the error in recovering vv.

The extension a focus distance is read from, against the error in reading itHow far a 50 mm lens stands beyond its focal length when focused at each distance — 10.000 mm at 0.3 m, 2.632 mm at 1 m, 0.847 mm at 3 m, 0.251 mm at 10 m — falling as the focal length squared over the distance. Beside it, the ±0.018 mm to which the principal distance is recovered with vanishing points read to ±0.25 px, which does not depend on the focus. The distance is read from the extension, so once the extension is less than ten times that band — from about 20 m — the distance comes back as an interval tens of per cent wide rather than a number.0.30.71.537200.1110distance the lens is focused at (m, log scale)millimetres (log scale)extensionreading errorthe band is ±0.018 mm at every focus50 mm lens
Fig. 2 How far a 50 mm lens stands beyond its focal length when focused at each distance — 10.000 mm at 0.3 m, 2.632 mm at 1 m, 0.847 mm at 3 m and 0.251 mm at 10 m — beside the ±0.018 mm to which vanishing points read to ±0.25 px recover the principal distance, a band that does not change with the focus.

The extension is f2/(uf)f^2/(u - f). For the 50 mm lens it is 10.000 mm at 30 cm, 2.632 mm at one metre, 0.847 mm at three and 0.251 mm at ten: it falls almost as one over the distance. The error in recovering vv does not fall at all. With each vanishing point read to a quarter of a pixel on a picture 690 pixels across a 36 mm sensor, the principal distance is known to ±0.018 mm, at every focus setting, because the vanishing points’ positions do not care where the lens was focused.

So the ratio of signal to error falls as the distance grows, and the error in the distance grows faster than the distance. Differentiating the equation, an error δv\delta v in the principal distance becomes

δu=(uf)2f2δv,\delta u = \frac{(u - f)^2}{f^2}\,\delta v,

and as a fraction of the distance that is close to uδv/f2u\,\delta v/f^2. The per-cent error grows in proportion to the distance itself. At one metre, 1000×0.018/25001000 \times 0.018/2500 is 0.72 per cent, and the figure measures 0.7; at five metres the rule gives 3.6 and the figure 3.7.

Past that the rule stops being a good description, because the error is no longer small. At thirty metres the extension is 0.083 mm, under five times the band. Read the principal distance at the low end of its band and the extension shrinks by a fifth, and since the distance goes as one over the extension, the upper end of the recovered interval runs away — 28 per cent beyond thirty metres, where the linear rule said 22. At a pixel of reading error instead of a quarter, the band is four times wider, nearly the whole extension at thirty metres, and the upper end has gone 755 per cent out. From about twenty metres, where the extension is less than ten times the band, what comes back is an interval tens of per cent wide rather than a number.

A finer reading and a longer lens buy the same thing

Two quantities are under the photographer’s control in the formula: the reading error and the focal length. They enter as a ratio.

A focus distance read from a picture, and how its precision falls awayA 50 mm unit-focusing lens focused at 0.3 to 30 m. The picture's principal distance is recovered from two vanishing points, and with the engraved focal length it gives back the distance the lens was focused at — exactly, from exact vanishing points. With each vanishing point read to ±0.0625 px, the recovered distance can be out by up to 0.2 % at 1 m, 0.9 % at 5 m and 6 % at 30 m. At ±0.25 px it is 0.7 % at 1 m and 28 % at 30 m.0.30.71.537200.10.3131030distance the lens is focused at (m, log scale)how far the recovered distance can be out (% , log scale)vanishing points ±0.0625 pxvanishing points ±0.25 px±0.0625 px: 0.2 % at 1 m → 6 % at 30 m50 mm lens
Fig. 3 The same recovery with the vanishing points read four times as precisely. At ±0.0625 px the distance can be out by up to 0.2 % at 1 m, 0.9 % at 5 m and 6 % at 30 m, against 0.7 % at 1 m and 28 % at 30 m at ±0.25 px.

Read the vanishing points to a sixteenth of a pixel instead of a quarter and every error falls by about four: 0.2 per cent at one metre, 0.9 at five, and 6 at thirty, where the quarter-pixel reading had 28. The per-cent error is proportional to the reading error, so a reading four times finer holds the same per cent to four times the distance.

A longer lens reads its focus distance betterThe same recovery for lenses of 24, 50, 100 mm, each vanishing point read to ±0.25 px. At 5 m the recovered distance can be out by 18.8 % with the 24 mm, 3.7 % with the 50 mm, 0.9 % with the 100 mm; at 30 m by an unbounded amount with the 24 mm, 28 % with the 50 mm, 6 % with the 100 mm. The extension a distance is read from grows as the square of the focal length, and the picture of a longer lens measures its principal distance in larger pixels.0.30.71.537200.11101001000distance the lens is focused at (m, log scale)how far the recovered distance can be out (%, log scale)24 mm50 mm100 mmat 5 m: 24 mm 18.8 % · 50 mm 3.7 % · 100 mm 0.9 %vanishing points ±0.25 px
Fig. 4 The recovery for 24, 50 and 100 mm lenses, vanishing points read to ±0.25 px. At 5 m the distance can be out by 18.8 %, 3.7 % and 0.9 %; at 30 m by an unbounded amount with the 24 mm, 28 % with the 50 mm and 6 % with the 100 mm.

A longer lens does the same thing through the other factor. At five metres, the 24 mm lens recovers the distance to 18.8 per cent, the 50 mm to 3.7 and the 100 mm to 0.9; at thirty metres the 24 mm lens gives no bound at all, the 50 mm 28 per cent and the 100 mm 6. Doubling the focal length divides the error by four, because the extension grows as the focal length squared — and a 100 mm lens at a quarter pixel gives the 0.9 and 6 per cent that the 50 mm lens gave at a sixteenth.

This is the reverse of the conclusion focusing is a zoom reached about trust. There, a wide lens was the one whose engraving could be believed, because its extension is small; a portrait lens used close was furthest from its engraved camera. Here the size of the extension is the signal, so the lens whose engraving misdescribes the camera most is the lens that measures its distance best. The same number is a nuisance to one question and the answer to the other.

Where the reading error actually comes from

The figures read vanishing points to a quarter of a pixel on a picture 690 pixels across, which is 13 µm of sensor. What the formula needs is that length, not the pixel count, so a finer sensor with the same fraction-of-a-pixel precision would move every per cent down in proportion — a sensor 6,000 pixels across, read to a quarter of its own pixel, would do about nine times better.

That is not the limit in practice, and the limit has already been measured. A vanishing point is an intersection extrapolated from lines, often far outside the frame, and a lens is not a pinhole. A floor with a referent found that a recovery through a lens with a barrel coefficient of −0.05 cannot return a focal length better than 0.72 per cent of it, however many points are used, because the distortion the recovery does not model biases every line. For a 50 mm lens that floor is 0.36 mm on vv — twenty times the quarter-pixel band.

Against that floor the extension is 2.632 mm at one metre, seven times over; 0.847 mm at three metres, a little over twice; 0.505 mm at five metres, less than one and a half times; and 0.251 mm at ten, inside it. So through a mildly distorted 50 mm lens, a picture carries its distance usefully to two or three metres, which is the range at which portraits, still lifes and rooms are photographed, and not much beyond. Correcting the distortion first moves the floor down toward the quarter-pixel band; fitting a lens from straightness alone does that from the picture’s own lines, and whatever residual it leaves becomes the floor for this measurement instead.

A second frame reads the extension directly

Vanishing points are one way to read the principal distance and not the best one, because each is two extrapolated lines and the answer rests on two such intersections. A focus ring offers a better way, using the fact that gave this measurement its start.

Take two frames from the same place, one focused at infinity and one focused close. Focusing is a zoom: the close frame is the infinity frame scaled about the principal point by exactly v/fv/f, with no change of perspective, because the lens has moved and nothing else has. So the scale between the two frames is the ratio the equation needs, and the distance is

u=fss1,s=vf.u = f\,\frac{s}{s - 1}, \qquad s = \frac{v}{f}.

The scale is fitted from every mark the two frames share rather than from two intersections. Its error falls as the reading error over the root of the sum of the marks’ squared distances from the centre. A hundred marks with a typical distance of 300 px, each read to a quarter of a pixel, fix the scale to about one part in twelve thousand, which is 0.004 mm on the principal distance of a 50 mm lens — four times finer than the vanishing points’ band, with no right angle needed in the scene. Every per cent in the figures above would fall by that factor, and the distance at which the reading becomes an interval would move out by it.

What it does not escape is the square law. The scale still reads vfv - f, the extension still falls as one over the distance, and a reading four times finer holds a given per cent to four times the distance and no further. The route changes the constant; the lens decides the shape. It also asks something of the photographer that the single frame did not — a second exposure, taken from the same place before anything moved — and it is exactly the pair of frames a focus-bracketing camera already takes.

Where the lens was focused is not where the subject is

Everything so far recovers the distance at which the lens was focused. A subject is not required to be there. It is required to look sharp, and it looks sharp anywhere within the depth of field.

Where the lens was focused, against where the subject can beA 50 mm lens, its focus distance recovered from vanishing points read to ±0.25 px, beside the far half of its depth of field for a 0.03 mm circle of confusion. At 1 m the recovery is out by 0.7 %, and a subject is as sharp up to 1.6 % beyond at f/1.4, 3.3 % beyond at f/2.8, 10.0 % beyond at f/8. Both grow as the distance squared over the focal length squared, so at 1 m the sharp band is 2.4, 4.9, 15.0 times the recovery error, near N·c/σv = 2.3, 4.6, 13.0 with the principal distance read to ±0.018 mm, and following that ratio's exact form to 7 % wherever the band is short of infinity by a factor of three. At f/8 the band reaches infinity from 10.5 m.0.30.71.537200.11101001000distance the lens is focused at (m, log scale)how far beyond it (% , log scale)recovery ±0.25 pxsharp band f/1.4sharp band f/2.8sharp band f/8sharp band ÷ recovery at 1 m: f/1.4 2.4× · f/2.8 4.9× · f/8 15.0×50 mm · c = 0.03 mm
Fig. 5 The 50 mm lens’s recovered focus distance, read to ±0.25 px, against the far half of its depth of field for a 0.03 mm circle of confusion. At 1 m the recovery is out by 0.7 % and a subject is as sharp up to 1.6 %, 3.3 % and 10.0 % beyond at f/1.4, f/2.8 and f/8 — 2.4, 4.9 and 15.0 times the recovery error. At f/8 the band reaches infinity from 10.5 m.

At one metre, with the conventional 0.03 mm circle of confusion, a subject stays as sharp up to 1.6 per cent beyond the focus distance at f/1.4, 3.3 per cent at f/2.8 and 10.0 per cent at f/8. The recovery’s own error there is 0.7 per cent. The sharp band is 2.4, 4.9 and 15.0 times the recovery error.

And the ratio does not improve at any other distance or with any other lens, because the depth of field obeys the same law. The far half of the band is u(uf)/(Hu)u(u - f)/(H - u), with the hyperfocal distance HH satisfying f2=Nc(Hf)f^2 = Nc\,(H - f), which for a subject well inside HH is close to u2Nc/f2u^2 Nc/f^2 — the distance squared over the focal length squared again, with the aperture’s blur circle NcNc where the recovery had its reading error δv\delta v. Divide one by the other and the distance and the focal length cancel:

sharp bandrecovery errorNcδv,\frac{\text{sharp band}}{\text{recovery error}} \approx \frac{N c}{\delta v},

which is 2.3, 4.6 and 13.0 for the three apertures, with the exact form following the figure to 7 per cent wherever the band is short of infinity by a factor of three. Nearer the hyperfocal distance the band grows faster and the ratio with it; at f/8 the band has no far end at all beyond 10.5 m.

So there are two different questions and the picture answers them to different precisions. Where was the lens focused? To the recovery’s error. Where is the subject? To the depth of field, which is several times wider at any aperture a photographer would use, and fifteen times wider at f/8 — unless something outside the picture says the subject is exactly at focus, as an autofocus point placed on it does. A longer lens or a closer subject makes both better together and never changes which is larger.

The circle of confusion in that ratio is, as the sharp band is a decision argued, a choice about a reader rather than a property of a lens. Choosing it stricter narrows the band and makes the subject’s distance better known, but only by declaring more of the picture unsharp: the ratio is a statement about what the photographer will accept as in focus, compared with how well the vanishing points were read.

What the scale is good for

Suppose the subject is at focus — a face on which an autofocus point sat. Then the picture gives its distance, and the magnification f/(uf)f/(u - f) gives the size of everything at that distance. An error in the distance becomes an error in the magnification larger by the factor u/(uf)u/(u - f), 1.05 at one metre, so the 0.7 per cent in distance is about 0.74 in size. A face photographed at a metre is measured to about a millimetre, from one picture, with no ruler in the scene.

That is a different route from every other way of getting a size into a picture. Two views give shape and no size found that a second camera adds shape and never scale; a height from one photograph needed a known height standing in the scene. The focus ring is a ruler built into the camera, with a range: excellent at portrait distance, fair across a room, and useless at a landscape, where every lens is focused near infinity and the extension has gone.

What this does not settle

Unit focusing only. The thin lens moves as a whole, so its focal length is fixed and the engraving is the right ff. Most modern lenses focus internally, changing their own focal length as they focus; for those, the relation between principal distance and focus distance is a property of the particular design, and the engraving is not the number to put in the equation.

Distance from which plane. A real lens has two principal planes some millimetres apart, and the thin-lens uu is measured from the front one, not from the sensor mark engraved on a camera body. At portrait distances that is a fraction of a per cent; at close-up distances it is not, and the model here has no thickness.

A right angle to read. The principal distance is recovered from two perpendicular directions. A scene without a known right angle, or a picture with a principal point displaced from the centre, needs a different recovery, and the principal point is not the centre measured what the second costs.

Still open: whether sharpness itself locates the subject

The recovery fixes where the lens was focused and the depth of field fixes a band around it; inside that band, a subject’s blur is not zero but small, and its size grows with the subject’s distance from focus. A blur circle of measured diameter places a mark at one of two distances, one in front of focus and one behind — and the recovered focus distance says where the zero of that measurement is.

The question that leaves is whether the two readings combine: whether measuring each mark’s blur, against a focus distance read from the same picture’s vanishing points, returns the subject’s distance more precisely than the depth of field alone, how the in-front-or-behind ambiguity is resolved when both halves are sharp, and at what aperture the blur carries more distance information than the extension does.

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 calibrationCircle of confusiondepth of fieldFocal lengthscale ambiguitysingle-view metrologyThin lensVanishing point