Light and mirrors

How many lamps a drawing has

The shadow field recovers a lamp by intersecting drawn lines. Two lamps make that a partition rather than an intersection — and two centres fit any bundle better than one, on a one-lamp drawing as readily as on a two-lamp one, so a count is a decision that needs a noise level before it exists. A criterion built on a penalty instead of a noise level returns four.

Worth reading first: Two lamps and one map · The lamp, out of the picture.

The lamp, out of the picture establishes the construction the whole field runs on. Draw the line through each post’s top and the tip of its shadow; every one of those lines passes through the lamp’s image, because a top and a tip are two points of one real ray; two of them meet there and the third is a test.

The lamp comes out in rays and not in plan splits the residual that test produces and finds it diagnoses two different faults — a floor that is not flat, or a second light.

And there the field stops, one question short of what a reader with a photograph wants. Not is there more than one light. How many, and where.

The drawing, and the 2 centres it is being cut into5 posts, 10 drawn lines — one from each post's top through the tip of each shadow — and the 2 points they are being asked to pass through. Each line is drawn in the colour of the pencil it was assigned to. With the lamps 2.40 m apart and 1 pixel of clicking, this partition leaves 2.12 pixels against an expected 5.50.horizoncorrect from 19 cm, at 160 mm wide2 centres · 2.12 px
Fig. 1 A drawing of five posts lit by two lamps, with its ten lines cut into two pencils and each pencil’s centre found.

The object is a partition

With one lamp the bundle of drawn lines has one centre and finding it is an intersection — a least-squares point, in closed form, from a two-by-two solve.

With two lamps every post casts two shadows, so the drawing has two lines per post, and they belong to two different pencils. Nothing in the picture says which is which: a line is a line, and the labels the scene had are not in the ink.

So the object is a partition before it is an intersection, and the partition is the work. It is solved here the way such things are always solved — assign every line to the centre it passes nearest, refit every centre from the lines assigned to it, repeat — from a dozen different starts, keeping the best.

That is k-means with a point-to-line distance, and it inherits k-means’s hazard: a start that drops two centres inside one pencil converges to something that looks like an answer. The starts are pairwise intersections of real lines rather than random points, because a centre far from every line collects nothing on the first pass and stays empty for ever.

Two centres always fit better

Here is the refusal the whole count rests on, and it is not a subtlety.

Take a drawing made by one lamp, with a pixel of clicking on every point. Fit one centre: the residual is a few pixels. Fit two: it falls to a fraction of one. Not because there is a second lamp — there is not — but because two centres have four free numbers where the truth needs two, and four numbers fit ten lines better than two do.

Measured over eight drawings, the two-centre fit is better on every one of them, and the improvement is up to six pixels.

So a rule of the form the residual got smaller, so there is another light returns another light every time it is asked, on every drawing, whatever made it. A reader who counts lamps by watching a residual fall is counting free parameters.

What a residual is worth, which is not what it says

Before a count can be decided, one number has to be established that the field has never needed: what residual a correct fit should leave.

The obvious answer — about a pixel, since a pixel is what the reader clicked with — is wrong by a large factor, and the factor is geometry rather than noise.

A drawn line runs from a post’s top to its shadow’s tip, and those two points are a hand’s breadth apart in the picture. The lamp’s image is nowhere near that segment: on the arrangement here it lies between two and four and a half segment-lengths beyond the post’s top, on the opposite side from the tip, because the shadow runs away from the lamp and the line has to be produced backwards to reach it. A line drawn through two clicked points pivots about their midpoint, so the further the question is asked from that midpoint, the more a click is worth.

To first order the miss at a point PP is σ(1t)2+t2\sigma\sqrt{(1-t)^2 + t^2}, where tt is where PP falls along the segment when it is extended. At the middle of the segment that is σ/2\sigma/\sqrt2; four and a half segment-lengths outside it, which is where the lamp’s image sits, it is five and a half times σ\sigma.

A pixel clicked is not a pixel at the answerEach drawn line runs from a post's top to its shadow's tip, a hand's breadth apart in the picture, and the lamp's image is far outside that segment. The horizontal axis is where the centre falls along the segment when it is produced — 0 is the post's top and 1 is the shadow's tip, and every value here is negative, because the lamp's image is behind the top on the far side from the tip. The vertical is how far a pixel of clicking moves the line at the centre. The mean over this drawing is 5.53, so a residual of five pixels is what a careful reader produces rather than evidence of a second lamp.0246-4-3.50-3-2.50where the centre falls along the drawn segment, produced backwardshow many pixels at the centre, per pixel clickedmean 5.53×five posts, one lampworst 7.08× · mean 5.53×
Fig. 2 How far a pixel of clicking travels by the time it reaches the centre, line by line, against how far outside the drawn segment the centre falls.

Measured on this drawing the mean factor is 5.5 and the worst is 7.1. So a one-lamp drawing clicked to a pixel leaves a residual of about five pixels, and a reader told “the residual is five pixels” learns nothing at all until the leverage is computed.

That is the same species of finding as the ladder of conditioning — a pixel costs different amounts depending on what is being asked of it — and it is why every criterion below is stated against a computed expectation rather than against the noise.

And the leverage is a height ratio

The parameter tt is not free: the arrangement fixes it, and writing it down turns the leverage from a measured 5.5 into something a reader can predict before clicking anything.

The lamp, the post’s top and the shadow’s tip are collinear, with the top between the other two, and similar triangles put the lamp (Hh)/h(H-h)/h segment-lengths beyond the top for a lamp at height HH and a post of height hh. So

t  =  Hhh,leverage  =  (1t)2+t2    2Hhht \;=\; -\frac{H-h}{h}, \qquad \text{leverage} \;=\; \sqrt{(1-t)^{2}+t^{2}} \;\approx\; \sqrt2\,\frac{H-h}{h}

for anything but the shortest extension. The drawing’s mean of 5.5 and worst of 7.1 correspond to extensions of 3.4 and 4.5 segment-lengths, that is to lamp-to-post height ratios of about 4.4 and 5.5 — a metre-tall lamp over posts a fifth of its height, which is the arrangement drawn.

So the leverage is the lamp’s height above the posts divided by the posts’ own height, and it is the reciprocal of the conditioning the two-lamp ratio reports for a different question on the same geometry. One arrangement, two measurements, and the same ratio deciding both — in opposite directions, since a tall post under a low lamp reads its shadow’s size badly and its lamp’s position well.

That gives the drawing rule the criterion needs. Use the tallest objects available: doubling a post’s height halves the leverage, halves the expected residual, and halves the number of pixels a reader has to be able to click to. A drawing of a room with a lamp at 2.4 m reads its lamp count from a 1.2 m chair back at a leverage of 1.4, and from a 0.2 m book at a leverage of 15 — a factor of ten, decided entirely by which object is used and not at all by how carefully the marks are made.

The criterion that works

With the expectation in hand the rule is simple: take the smallest count whose residual is inside what the reader’s own clicking would have produced.

On a two-lamp drawing with the lamps 2.4 metres apart, one centre leaves 184 pixels against an expected 3.4 — fifty times outside. Two centres leave 2.1 against an expected 5.5, which is inside. The count is two, the centres land within a few pixels of the lamps’ true images, and every line is assigned to the lamp that actually cast it.

The residual against the number of lamps allowedThe same bundle fitted with one, two and three centres, at 2.4 m of separation and 1 px of clicking. The residual never rises: more centres always fit better. What decides the count is the dashed line — the residual the reader's own clicking produces at this drawing's leverage — and the first count that reaches it is 2.050100150123how many centres the bundle is allowedthe residual, in pixels184.5 px at one centrewhat 1 px of clicking produces heretwo lamps 2.4 m apart, five poststhe count against the noise: 2 · against a penalty: 2
Fig. 3 The residual against the number of centres allowed, with the expectation drawn as a dashed line. The first count that reaches it is the answer.

The criterion needs one thing and it is the thing the field has never had to state: how carefully the picture was clicked. That is not a defect of the method, it is the content of the question. A drawing does not contain a number of lamps; a drawing plus a claim about how well it was measured contains one, and a criterion that does not ask for the second is hiding the assumption rather than avoiding it.

The criterion that does not work, and why

There is a standard way to avoid stating a noise level, and it fails here in a way worth publishing.

Model selection normally scores a fit by its residual and charges it for its parameters — a term like Nln(rms2)+4mlnNN\ln(\text{rms}^2) + 4m\ln N, which rewards a good fit and taxes each extra centre. It needs no noise level, which is exactly its appeal.

Pointed at the two-lamp drawing above, it returns four.

The reason is visible in the residual curve. With ten lines and four centres, each pencil has two or three lines in it, and two lines meet exactly: the residual falls to 0.69 pixels and would fall to zero at five centres. A logarithm of something approaching zero runs to minus infinity, and no fixed penalty per parameter beats minus infinity.

So the honest statement is stronger than “the penalty is badly tuned”. A penalty cannot rescue a fit that can reach zero. Any criterion of that shape, at any tuning, eventually prefers as many centres as the data will support, and the only thing that stops it is knowing what residual a correct fit should leave — which is a noise level, which is what the penalty was introduced to avoid.

The residual against the number of lamps allowedThe same bundle fitted with one, two and three centres, at 2.4 m of separation and 4 px of clicking. The residual never rises: more centres always fit better. What decides the count is the dashed line — the residual the reader's own clicking produces at this drawing's leverage — and the first count that reaches it is 2.050100150123how many centres the bundle is allowedthe residual, in pixels183.5 px at one centrewhat 4 px of clicking produces heretwo lamps 2.4 m apart, five poststhe count against the noise: 2 · against a penalty: 2
Fig. 4 The same drawing clicked four times as carelessly, where the expectation rises with the noise and the chosen count does not change.

This is the third time this collection has found a summary statistic answering a question nobody asked. The single residual maximised two families together and lost which of them failed; the shadow residual compressed a structured field to a scalar; and here a criterion designed to need no assumptions makes one silently. The pattern is the same each time: a number that is cheap to compute stands in for one that requires an argument.

The partition, when it is right

When the count is right the assignment is right too, and that is not automatic — a fit could easily return two centres in the correct places with the wrong lines attached to each.

Measured over twelve drawings at each separation, the share of lines assigned to the lamp that cast them is 100 per cent from twenty centimetres of separation upward, and it stays above 84 per cent even at five centimetres, where the count itself has collapsed to one. The assignment is the easy half; the count is the hard one.

That ordering has a reason. Two nearly coincident lamps produce nearly coincident pencils, and a line’s distance to two nearly coincident centres is nearly the same — so the assignment is nearly arbitrary and nearly harmless, because either choice puts the line in a pencil whose centre is within a few pixels of the other. The count is where the damage lands, because a count is a discrete claim and cannot be nearly right.

Where two lamps become oneTwelve drawings at each separation, each with its own clicking, and how often the count comes back as two. It is not a threshold with a yes on one side: at 0.10 m the same two lamps are read as two in some drawings and as one in others. Below that the drawing genuinely does not contain the second lamp — every line in it is within the reader's clicking of a single pencil.00.2500.5000.7501-1-0.50000.500how far apart the lamps are, log₁₀ metreshow often the drawing is read as two lampshalf the drawings1 px of clicking, 12 drawings each, separated across the viewbelow the crossing the second lamp is not in the picture
Fig. 5 How often the count comes back as two, against how far apart the lamps are. The distance at which they part is the next rung’s subject.

What the answer is, in the end

A drawing of five posts and their shadows, clicked to a pixel, with two lamps two metres or more apart, yields:

Two centres, each within a few pixels of a lamp’s own image, from a partition every one of whose assignments is correct.

A residual inside the expectation, which is what licenses stopping at two rather than trying three.

And nothing at all about the lamps’ distances, because these are points in the picture. Turning an image into a place in the room needs the horizon and the ground plane, which is the second half of the original recovery and is exactly the half that a floor which is not flat destroys. The count is a fact about the drawing; the positions are a fact about the drawing plus a model of the room.

What two centres are worth once they are found

A count is a means rather than an end, and the pair of image points it produces is a richer object than either alone.

Two lamps and one map establishes what the two shadows of a flat object are: one is the other scaled about a point, a homothety whose ratio is exactly 1 when the two lamps are at the same height. So a reader with two recovered centres has, immediately, a statement about the relative heights of two lights that were never in the picture — from ink alone, with no calibration.

The chain is worth setting out because each link is a rung this collection already has. The partition gives two pencils; each pencil’s intersection is a lamp’s image; the two ground families give two feet; and the map between the two shadows of one object is a homothety whose centre and ratio the pair fixes. Nothing in that requires the room. The room enters only when a reader wants metres, and it enters through the horizon exactly as it does for one lamp.

There is a check available too, and it is the kind this collection likes: the homothety measured directly between two drawn shadows has to agree with the ratio computed from the two recovered centres. Two routes to one number, neither of which knows the other.

One shadow is the other, scaledThe map from one lamp's shadow to the other's is a homothety — a scaling about one point, with ratio 1.2509 — and it carries every point of the first outline onto the second to 1e-15 m. There is no rotation and no shear available to it, because a projection between two parallel planes has its axis at infinity, and a homology with its axis at infinity is a scaling.correct from 19 cm, at 160 mm wideratio 1.2509 · carries one onto the other to 1e-15 m
Fig. 6 The map between two shadows of one object, whose ratio the two recovered centres also predict.

The drawing has to be a scatter and not a row

One arrangement defeats the method entirely, and it is the arrangement a photographer is most likely to hand it.

The original recovery records the degenerate case: a row of posts strung out along the direction their shadows run gives collinear shadow segments, no vanishing point exists, and the least-squares fit is singular. The row has to cross the view.

A count is more sensitive to it than a single recovery, and for a reason the partition makes obvious. Two nearly parallel pencils are exactly what a partition cannot resolve — every line is nearly the same distance from both candidate centres, so the assignment is arbitrary and the two centres wander along the direction the lines fail to span. The posts here are therefore scattered across the view on purpose, and the spread is a parameter rather than a convenience.

A reader with a real photograph should look for the same thing before trusting any of this: posts at several bearings, so that the drawn lines point in several directions. Bollards along a kerb are the bad case; bollards, a person and a bicycle at different places in the frame are the good one.

The drawing, and the 2 centres it is being cut into5 posts, 10 drawn lines — one from each post's top through the tip of each shadow — and the 2 points they are being asked to pass through. Each line is drawn in the colour of the pencil it was assigned to. With the lamps 0.60 m apart and 1 pixel of clicking, this partition leaves 2.29 pixels against an expected 5.50.horizoncorrect from 19 cm, at 160 mm wide2 centres · 2.29 px
Fig. 7 Two lamps closer together, where the two pencils are nearly parallel and the partition begins to be arbitrary.

Why the alternation needs restarts

One implementation detail is worth a paragraph because leaving it out is the most likely way to reproduce this and get a different answer.

The partition is found by alternation, and alternation converges to a local minimum of whatever it is started from. A start that drops both centres inside one real pencil converges to a division of that pencil into two halves, leaving the other pencil’s lines attached to whichever centre is nearer — a partition that is stable, has a plausible residual, and is wrong.

The defence is a dozen starts, each from the intersection of two lines chosen at random, keeping the best. The starts are intersections of real lines rather than random points for a specific reason: a centre placed at random is far from every line, collects nothing on the first assignment, and stays empty for ever, so the run is quietly a one-centre fit wearing a two-centre label.

The spread across restarts is worth reporting as well as the winner, and it is the honest diagnostic for whether a partition is trustworthy: when the lamps are well separated every start converges to the same answer, and when they are close the restarts scatter. A single run that happens to land well tells a reader nothing about which regime they are in.

What is not in the count

Three things the method cannot see, stated so that a reader does not ask it for them.

An area source is not two lamps. A wide source produces a penumbra rather than two shadows, and its rays do not form two pencils — they form a continuum. The penumbra is the lamp’s image measures that case, and a count run on a drawing whose edges are soft is measuring where somebody clicked on a gradient.

Reflected light is a lamp. A mirror produces a second centre of projection, exactly, and this construction counts it as a second lamp — which is right, since a mirror is a second camera and its image of a lamp is a lamp. A reader after sources rather than centres has to distinguish them another way.

And a lamp behind the camera is still counted, which sounds like a limitation and is the opposite; it comes out of the picture like any other, at the point the reversed divide puts it.

A 35 cm source, an edge, and the band betweenThe penumbra is 17.5 cm wide by the projection — the source's width times the receiver-to-occluder distance over the source-to-occluder distance — and 17.4 cm by counting how much of the source each point can see. The two routes share no arithmetic.source, 35 cmthe occluder's edgefraction of the source visiblepenumbra 17.5 cmprojection: 17.50 cmsampled: 17.41 cm
Fig. 8 The case that is not two lamps: a source with width, whose shadow edge is a gradient rather than two lines.

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.

Conditioningerror propagationIdentifiabilityleast-squares intersectionLight recoveryModel errorOverfittingPencilPoint lightResidual