How many lamps a drawing has
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 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 is , where is where falls along the segment when it is extended. At the middle of the segment that is ; four and a half segment-lengths outside it, which is where the lamp’s image sits, it is five and a half times .
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 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 segment-lengths beyond the top for a lamp at height and a post of height . So
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 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 , 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.
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.
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.
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.
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.
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.
- The wedge recovered with the camera — both name conditioning, identifiability, model error, residual
- A fitted radius is wrong before it is uncertain — both name conditioning, model error, residual
- A floor with a referent — both name conditioning, model error, residual
- A fold names the height — both name conditioning, identifiability, residual
- A light far enough away — both name conditioning, error propagation, light recovery
- A pane gives a product before it gives two numbers — both name conditioning, model error, residual
Named objects
A flat tag is an object no other essay names yet.
Conditioningerror propagationIdentifiabilityleast-squares intersectionLight recoveryModel errorOverfittingPencilPoint lightResidual