Light and mirrors

The lamp, out of the picture

Two posts and their shadows put the light's position in a photograph, exactly, with nothing given but the drawn lines and the camera's own horizon. Two posts. One gives a residual of zero and an answer that is a whole one-parameter family — the sharpest counter-example this site has to the idea that a small residual means a right answer, met again in a new field.

Worth reading first: Where shadows vanish · Recovering the camera from the picture it drew.

This site recovers cameras from the pictures they drew, and the reason to do it is not that anybody needs the camera. It is that a recovery is a test the geometry can fail: draw from a known camera, forget it, get it back from the drawn edges alone, and compare. The lamp is the other centre of projection in the same picture, and it can be recovered the same way.

The lamp, from the shadows aloneThe two intersections are the light and the point below it. Nothing about the lamp was given to the construction — it is shown three posts, three shadow tips and the camera's own horizon — and the recovered position is 1e-12 mm from the truth. The light's foot sits 351 px below the horizon, which is what says it is a lamp and not the sun.the shadow lines meet below the horizon — a lamp in the roomhorizoncorrect from 25 cm, at 160 mm wide3 posts · foot 351 px below the horizon
Fig. 1 Three posts, their shadow tips, and the two intersections that place the light. The construction is shown the drawn points and the camera’s horizon and nothing else; the recovered lamp is where the lamp was, to a fraction of a nanometre.

Two lines and two points

Two facts do all of it and neither requires the camera to be calibrated.

The line from a post’s top through the tip of its shadow passes through the light. That is what casting a shadow means. So the images of those lines, for two posts, meet at the image of the light.

The line from a post’s foot through the same tip lies in the ground plane and passes under the light. So the images of those lines meet at the image of the point on the ground directly below the light.

Two intersections, and they are vertically apart in space. The rest is arithmetic: the foot’s image is a point of the ground plane, so its world position comes from intersecting its ray with y=0y = 0; and the light lies on its own ray, above that foot.

Three residuals, and only one of them is a test

The construction produces three numbers that could be wrong, and it is worth separating them because two of them are self-consistency and one is truth.

Agreement between posts, in pixels. The intersection is taken from two posts and there is a third. If the scene were lit by two lamps, or if a shadow tip had been placed by hand, the third post’s lines would miss the fitted points. They miss by 101410^{-14} px, which says the scene is lit by one light.

Closure in space, in metres. The lamp’s own ray and the vertical through its recovered foot are two lines in space, and two lines in space are not obliged to meet. Solving them as a least-squares closest approach rather than as an intersection returns both the answer and the distance between them at their nearest — the only quantity in the construction that could report a failure. An intersection routine cannot; it would return a point either way.

The error against truth, in millimetres. The one comparison against something the recovery never saw. The lamp comes back where it was put.

The first two are checks a reader with a real photograph can perform. The third is available only because the picture was drawn from a known lamp, which is the whole reason this site draws its own pictures.

A box and its shadow, both projections from a pointThe rays from the lamp to the corners are the same construction as the rays from the eye to the corners — one operation, two centres.correct from 26 cm, at 160 mm wide34° across
Fig. 2 The forward operation the recovery inverts. A solid and its shadow, both computed from the lamp as a centre of projection — and the recovery is shown only the drawn result.

Telling a lamp from the sun

The construction does not need to be told which it is looking at, and where the foot lands is the answer.

The same construction, in sunlightThe lines through top and shadow tip are parallel in space, so their images meet at a vanishing point — and the lines through foot and tip meet ON the horizon, 5e-12 px off it. A light whose foot is on the horizon is a light at infinity.the shadow lines meet on the horizon — a light at infinityhorizoncorrect from 25 cm, at 160 mm wide3 posts · foot 5e-12 px off the horizon
Fig. 3 The identical construction in sunlight. The shadow lines are parallel in space, so their images meet at a vanishing point — and the foot-lines meet ON the horizon rather than below it. A light whose foot is at infinity is a light at infinity.

Under the sun, the shadow-direction lines are parallel in space, so their images converge at a point on the horizon, which is where shadows vanish. The point where the foot-lines meet is 101210^{-12} px from the horizon, which is zero to any standard a photograph could set. Under a lamp it is a few hundred pixels below it.

So there is no separate test for is this the sun. There is one construction, and the answer is a point; if the point is on the horizon the light is at infinity, and the sun is the case of the light being at infinity. That is the same collapse the limit rung makes for parallel projection and the shadow rung makes for shadows generally, appearing for a third time.

Shadow length against the sun's elevationA 1 m post casts a 1 m shadow at 45° and a 5.7 m shadow at 10°. The curve is a cotangent and it has no upper bound.02.5057.501020406080elevation of the sun (degrees)length of the shadow of a 1 m post (m)45° — shadow equals heightcot of the elevationunbounded as the sun sets
Fig. 4 The one-number version, for contrast. A single vertical’s shadow length gives the light’s altitude and nothing else — one measurement, one unknown, and no way of telling whether the picture is consistent.

One post, and the residual that means nothing

Now take away a post. With one post there is one ray-line and one ground-line, they intersect nothing, and there is no answer.

The temptation is to fit anyway. A single post plus a least-squares solver produces a point — the nearest point on the line, or whatever the parameterisation happens to prefer — and it produces it with a residual of exactly zero, because a system with fewer equations than unknowns has a solution space rather than a solution, and any member of it fits perfectly by construction.

The honest report is the family. Every lamp along the ray from the post’s top through its shadow tip casts exactly that shadow of that post: the shadow tip is where the line hits the ground, and moving the lamp along the line does not move it. Nine of them, spread over two and a half metres of the ray, all cast the identical shadow to a fraction of a millimetre.

This is the applied phase’s sharpest gotcha met again in a field it had nothing to do with. There it was a camera recovered from a picture with an unmodelled pixel aspect: the focal length came back 49.6% short, the spread across three independent estimates was exactly zero, and the worst bundle residual was 9.1×10139.1\times10^{-13} px. Every alarm at its theoretical best, because a fit with fewer equations than unknowns produces a family and picks one.

A residual reports over-determination failing. It says nothing about under-determination. The number to look at is not the residual but the count of independent constraints against the count of unknowns, and the construction here has an exact version of that count: two posts is the minimum, and the third is what turns the answer into a test.

The lamp, from the shadows aloneThe two intersections are the light and the point below it. Nothing about the lamp was given to the construction — it is shown three posts, three shadow tips and the camera's own horizon — and the recovered position is 1e-12 mm from the truth. The light's foot sits 351 px below the horizon, which is what says it is a lamp and not the sun.the shadow lines meet below the horizon — a lamp in the roomhorizoncorrect from 25 cm, at 160 mm wide2 posts · foot 351 px below the horizon
Fig. 5 The minimum case, with the third post removed. The answer is the same answer and there is no longer anything checking it — two posts determine the light and cannot say whether the picture is consistent. The residual is zero because there is nothing left over for it to be computed from.
What one pixel of click error costs, against distanceA 1.83 m object at 3 m is measured to 0.28% per pixel; the same object at 201 m to 18.2% per pixel. The whole object shrinks toward the horizon, so a pixel buys more world.05101550100150200distance from the camera (metres)error in the recovered height, per pixel of click error (%)5 m — 0.46%25 m — 2.27%100 m — 9.04%190 m — 17.16%one pixel, on a 690 px picturelinear in distance
Fig. 6 How a pixel of misplacement propagates in a one-view measurement. The lamp recovery has the same structure — two intersections read off drawn lines — so its sensitivity is of this kind, and it grows as the lines become more nearly parallel.

What it costs to be wrong about the ground

The construction assumes the shadows fall on one flat plane, and that assumption is doing real work: the foot-lines have to be lines in the ground plane for their intersection to be the light’s foot.

If the ground is not flat, the shadow tips are not where the flat-ground calculation puts them, and the two intersections drift apart — which shows up in the closure distance rather than in the pixel residual. That is a useful division of labour: the pixel residual catches a picture that was not lit by one light, and the closure catches a picture whose ground is not one plane. Two failure modes, two numbers, neither of which can mask the other.

Un-casting a shadow off a curved floorFitting the map from four marks and predicting the rest: exact at the four, and wrong by up to 8.75 mm everywhere else. A shadow on a plane is a homography and can be inverted from four points; a shadow on anything else is not, and the four points still fit perfectly.the floor is dished — four points fitted, the rest predictedcorrect from 20 cm, at 160 mm widefour points fitted · worst 8.75 mm
Fig. 7 The related failure, taken apart in the un-casting rung. A shadow on a plane is a projectivity and four marks determine it; a shadow on anything else is not, and the four marks still fit perfectly while everything between them is wrong.
A box drawn from a known camera, and the camera recovered from the drawingThree vanishing points found from the twelve drawn edges alone give back the focal length to 2e-15 relative.recovered principal pointused to drawrecoveredgapfocal length898.76898.762e-15principal x345.0345.06e-13angle42.0°42.0°correct from 21 cm, at 160 mm wide42° across
Fig. 8 The recovery this one is modelled on. The camera comes out of the drawn edges of a box; the lamp comes out of the drawn lines of a shadow; and both are worth what they are worth because the only thing crossing between the two halves is a list of line segments.

What the recovery is worth

Two uses, and the second is the one that matters here.

Forensically, the light’s position in a photograph is a strong consistency constraint. An object composited into a scene brings its own lighting, and the geometry of a cast shadow is unforgiving in a way that its softness and colour are not: the shadow tip has to be on the line from the light through the top of the thing, and that is one linear condition per object with no adjustable parameters.

And as a check on the site’s own machinery, this is a round trip in a field that did not have one. The foundations field recovers the camera; the twoviews and manyviews fields recover cameras and structure together; the metrology field recovers lengths. The light field, until this rung, cast shadows and never got anything back out of them. A construction that only goes forwards is a construction whose errors accumulate silently, because nothing is ever compared with anything.

Six posts in sunlight from 28°The shadows are parallel in the world, so in the picture they meet at one point on the horizon — found from the drawn shadows to 6e-13 px.horizonshadows meet herethe shadows' vanishing point is in frameon the horizon, as it must be
Fig. 9 The rung below, which established the two vanishing points this construction intersects. What is added here is the step from the shadows converge to a point to therefore the light is here, in metres — the difference between a consistency check and a measurement.
Two triangles in perspective from a pointCorresponding vertices lie on three lines through one centre. Pair off the corresponding SIDES instead and the three points where they meet are collinear — 3e-13 px from the line through them, at every configuration the slider reaches. Nothing was measured to make that happen, and nothing can be adjusted to improve it.three side intersections, collinear to 3e-13 pxcentrethree sides paired, three pointscollinear to 3e-13 px
Fig. 10 The theorem that guarantees a shadow construction closes. An object and its shadow are in perspective from the lamp, so their corresponding sides meet on one line — which is why a hand construction meets where it is supposed to, and why that meeting is not evidence of accuracy.

Why the construction needs no calibration

The recovery uses the camera’s horizon and nothing else about the camera, and that is worth dwelling on because most recoveries on this site need a focal length.

The reason is that both intersections are found in the picture. The lines through top-and-tip are drawn lines; their intersection is a drawn point; the same for the foot-and-tip lines. Neither step asks where the camera was or what lens it had. What the horizon supplies is the interpretation — a point below the horizon is a point of the ground plane in front of the camera, and a point on the horizon is a direction — and the horizon is itself findable in the picture from any two pairs of lines parallel on the ground.

So the image of the light and the image of its foot come out of a photograph with a straightedge, with no calibration at all. What needs the camera is only the last step: turning those two image points into metres, which requires knowing the ray each corresponds to, and that is the focal length’s job.

That division is worth keeping in mind because the first half is the half that catches inconsistency. Whether every post agrees about where the light is, and whether the light is at infinity or in the room, are both answered before any camera parameter is used.

Why the two intersections are the right two

There are several pairs of lines in the picture that could be intersected, and the construction picks two. It is worth saying why those two and not others, because the choice is what makes the answer the light rather than something else.

Top through tip gives the light itself. A shadow tip is where the ray from the light through the object’s top meets the ground, so the light, the top and the tip are collinear in space — and a projection preserves collinearity, so their images are collinear too. Two such lines, from two objects, share exactly one point in space: the light. Their images therefore share the light’s image.

Foot through tip gives the light’s foot. The foot and the tip are both on the ground, and so is the point directly below the light; the three are collinear because the vertical plane through the light and the object cuts the ground in that line. Two of those lines meet at the point below the light.

And every other pair gives nothing. Top through foot is the object itself, and two objects’ verticals meet at the vertical vanishing point — a real point of the picture, and a fact about the camera rather than about the light. Tip through tip is a line with no meaning at all.

So the construction is not a choice among several workable pairs. It is the only pair of families of lines in the picture that pass through the two points wanted, and the reason there are exactly two useful families is that a lamp has exactly two things worth locating: where it is, and where it is above.

The three ways a picture fails this test

Each of the construction’s numbers catches a different kind of wrong picture, and they cannot substitute for each other.

Two lamps. With more than one light source, different posts’ lines meet at different points, and the pixel residual against the fitted intersection grows. Two lamps at opposite ends of a room give a residual of hundreds of pixels; two nearly coincident ones give a small residual and are, correctly, nearly one lamp.

A ground that is not a plane. The foot-lines are only lines of the ground plane if the ground is a plane, so a floor with a step in it puts the shadow tips somewhere the flat calculation does not expect. That shows up in the closure distance between the lamp’s ray and the vertical through its foot, in metres, and not in the pixel residual.

And a shadow that was drawn rather than cast. The most common failure in constructed images, and it fails both tests at once — a hand-placed shadow tip has no reason to lie on the line from the light through the object’s top, so the picture is inconsistent before any of the arithmetic runs.

What the recovery would need to be a forensic tool

It is worth being honest about the gap between the geometry here and what a real photograph would demand, because the geometry is exact and the photograph is not.

The construction takes exact points. A real photograph supplies a shadow tip that is soft, several pixels wide, and ambiguous by more than that where the shadow runs onto grass or a kerb. The residual that reads 5.7e-14 px on a drawn figure would read a few pixels on a photograph, and the question would become whether a few pixels is consistent with one light — which needs an error model that this site does not build.

What survives the move to a real photograph is the structure: two intersections, a foot on or below the horizon, and a closure in metres. The numbers become uncertainties instead of certainties, and the three failure modes stay distinguishable, which is the part worth having.

The construction as a reader can use it

On a photograph with two or more vertical objects whose feet and shadow tips are visible, with a straightedge:

Draw the line from each object’s top through its shadow tip. Where they cross is the light in the picture. Draw the line from each foot through the same tip. Where those cross is the point under the light. If that second point is on the horizon, the light is the sun; if it is below, it is a lamp, and the vertical between the two crossings is the lamp’s height in the picture’s own units — which becomes metres as soon as anything in the picture has a known length, by the same cross-ratio the height from one photograph uses.

A 3.4 m object measured from one picture, 11 m awayThe base, the horizon crossing, the top and the vertical vanishing point have a cross-ratio of 1.9101. With the eye at 1.62 m that gives 3.400 m, against a true 3.4 m. The camera is not consulted.horizon — the eye's own heightbase — 0 mhorizon crossing — 1.62 mtop — 3.40 m recoveredthe vertical vanishing point is 8586 px above this framerecovered 3.400 m · true 3.400 m1.8 cm per pixel of click error
Fig. 11 The step that turns the picture’s units into metres, from the metrology field. One known height anywhere in the scene, and every other vertical — including the recovered lamp — is measurable off the same horizon.

Two objects. And with one, the answer is a line, and a solver that reports a point is reporting its own preferences.

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.

centre of projectiongauge freedomHorizonInverse projectionleast-squares intersectionPoint lightreconstruction ambiguityResidualshadow vanishing pointsingle-view metrology