Undoing a picture made on a curve
Worth reading first: When the picture surface is not flat · The floor that is not a plane.
Three separate arguments on this site have measured what happens when a picture is made on a surface that is not flat. A shadow cast onto a dished floor departs from any homography by 5.67 mm, and onto a ridged one by 9.07 mm. An anamorph laid out for a vault instead of a flat floor differs from the flat design by 529.4 mm. Every one of those is a measurement of the forward direction: put something onto the surface and see how far it is from what a plane would have given.
None of them is the question a reader with a photograph actually has, which is the other way round. There is a design on that curved floor. Can it be got back?
The answer is yes, exactly, and the price is a single sentence: the surface has to be supplied. What follows is what that means, what it costs not to, and what it means for the recovery to be exact at all.
What “the design” means on a curved floor
Before anything can be recovered, it has to be said what is there to recover, and on a curved surface that is not obvious.
Take a signwriter laying out lettering on a floor that dips. They do not work from a plan; they work with a flexible rule laid along the surface, measuring distances on the floor. The result is a design that is exactly rectangular when measured that way, and not rectangular at all when measured on the plan.
That is the object this essay recovers: the design in the surface’s own coordinates, which are arc lengths along it. Those coordinates exist for the ridge — a ridged floor can be unrolled onto paper without stretching, so there is a genuine flat design and it is unique — and they do not exist for every surface. Which floors have them is a question with a sharp answer and an essay of its own; for now the ridge does, and that is what makes the recovery well posed rather than a matter of choice.
The recovery, in three exact steps
Given a photograph and the floor, the undo is a composition of three maps, none of which is a fit.
From the picture to a ray. An image point names a direction from the eye: the camera’s basis, its focal length, its principal point. Exact.
From the ray to the surface. Follow the ray until it crosses the floor. For a shape given as a height field this is a root-find rather than a formula — deliberately, because the family of floors here includes a step, which is not a quadric anybody wants to solve by hand, and a solver that only handled quadrics would have quietly excluded it.
From the surface to the design. The point on the floor has a position in the floor’s own arc-length coordinates. Exact, in closed form for the ridge: the arc length along a parabola integrates to
written out rather than integrated numerically, because it is the thing being claimed exact and a quadrature’s own error would be indistinguishable from the surface failing to unroll.
Compose the three and the design comes back at 1.1e-12 mm — which is arithmetic and not accuracy. There is no least-squares step anywhere in the chain, so there is no residual to report and no conditioning to worry about. That is the sense in which knowing the surface is enough: it is not that the recovery becomes good, it is that it stops being an estimate.
And what it costs to guess
The interesting number is the other one: what happens to somebody who has the photograph and no plan of the building.
They do what every rectification tool offers. Mark four points whose positions in the design are known — four corners of a panel, four registration marks — and fit the homography that carries them there. Four correspondences determine one exactly, so this always works, and it is exact at the four.
Everywhere else it is 111 mm out, on a design 1800 mm across. Six per cent of the width, from a floor whose deviation from flat is a few centimetres.
That the flat fit is exact at its four marks is the control, and it matters. Without it, the 111 mm could be a badly conditioned solve rather than the shape of the floor. With it, the four marks come back to a hundredth of a micron and the rest do not, which localises the error precisely: the map is right where it was told and wrong where it was asked.
Two practical notes come out of the same figure, and both were errors before they were notes.
Choose the four marks at the corners. The first version of this recovery picked them at evenly spaced indices through a grid stored row by row, which selects four points down a diagonal — very nearly collinear — and the homography fitted to them reported the flat rectification as 4.18 m out. That number is about the sampling, not the floor. Four nearly-collinear correspondences is the same trap a shadow’s four-point fit met here before, and it does not announce itself: the solve succeeds and the answer is wild.
And a curved floor is not a wide-angle lens. The error above is not a distortion of the picture. It is a mismatch between two surfaces, and no amount of undistorting the photograph touches it.
Why the flat fit is wrong in the way it is
It is worth knowing the shape of the error, because it explains why it cannot be tuned away.
A homography of the plane is a map with eight parameters. The map from the photograph to the design, on a curved floor, is not in that eight-parameter family at all — it is a ray trace through a surface, and the surface has as many parameters as its shape does. Fitting a homography to it is not fitting an imperfect model; it is fitting a model of the wrong kind.
The tell is the pattern of residuals. Model error of the ordinary sort is noisy and shrinks when more data is used. This one is smooth, systematic, and grows toward the parts of the floor furthest from the four fitted marks — because the fit interpolates between them and extrapolates beyond them, and the surface’s departure from flat is a smooth function that the eight parameters have no way to absorb.
Adding more marks does not help either, and that is the diagnostic. A least-squares homography over twenty marks spreads the error more evenly and does not reduce its size, because there is no homography that fits. The residual after fitting twenty is a measurement of the floor.
A picture surface and a receiving surface
There is a symmetry here worth naming, because it turns this essay into a special case of something the site has been circling for a long time.
The curved field is about the surface a picture is formed on — a cylinder, a sphere, a fisheye’s focal surface. This essay is about the surface a picture is painted on before a camera looks at it. Those sound like different subjects and they are the same one seen from two ends.
In both cases the question is: given a map from directions to a two-dimensional thing, what does the two-dimensional thing being curved do to what can be recovered? And in both cases the answer is that the surface has to be supplied, because it is not in the picture.
A photograph of a fisheye picture does not carry the fisheye’s rule; a photograph of a painted floor does not carry the floor. Both are recoverable only from something else — a specification, a calibration, a plan — and both are exactly recoverable once supplied.
Why the ray trace has to be a root-find
A small point of construction that turns out to carry a claim.
The second step — from a ray to the surface — is done by bisecting on the signed height difference along the ray, rather than by solving a quadratic. For a dish or a ridge a closed form exists and would be quicker. It is not used, and the reason is the step.
step is two horizontal planes with a jump between them. It is developable, its plan is its development, and it is nonetheless the surface that broke the four-point fit worst of the four when a shadow was cast onto it. A solver written for quadrics would have had to special-case it or leave it out, and leaving it out is how a family of surfaces quietly becomes a family of smooth surfaces without anybody deciding that.
The bisection also produces the refusals honestly. A ray that never crosses the floor returns nothing rather than an extrapolated crossing, which is what a map on this site is required to do at its own boundary. One of those refusals turned out to contain a fact worth knowing: a ray aimed above the horizon meets no flat floor, and it does meet a ridged one, a long way off — a ridged floor is a parabolic trough, so it rises without bound at the sides. “Above the horizon” is a guard that belongs to the plane and to no other surface.
What has to be known, and what does not
The recovery needs the floor. It is worth being precise about which parts of “the floor”.
The shape, as a function. Not a rough idea of it: the actual height field, because the ray trace uses it pointwise.
The camera. Focal length, principal point, position and orientation, since the first of the three steps is the picture-to-ray map. In practice this is recovered from the same photograph by ordinary means, and the essays on the camera coming back out of its own picture are the route.
And nothing about the design. No known lengths, no assumed rectangle, no registration marks. That is the part worth noticing: the flat fit needs four known correspondences and gets the answer wrong; the exact recovery needs none and gets it right. The information was never in the marks, it was in the floor.
What a reader with a photograph should do
The result is worth turning into a procedure, because the wrong procedure is the default one everywhere.
Ask whether the surface is flat, and answer it with a measurement rather than a glance. A floor that dips by a few centimetres over two metres looks flat in a photograph and costs six per cent of the design. The relevant question is not whether it looks flat but whether its departure from flat, divided by the distance to the camera, is small compared with the accuracy wanted — and for a floor photographed from three metres, a two-centimetre dip is not.
If it is flat, four marks are the whole job, and the rectification is exact.
If it is not, get the surface — from a plan, a survey, a laser scan, or by fitting it from the same photograph if there is enough in the scene to fit it from. Then the recovery is exact and needs no known correspondences at all.
And check the residual at the marks the fit was not given. That is the one diagnostic that separates the two cases without any prior knowledge. Fit a homography to four marks, predict a fifth, and see how far off it is. On a flat floor it lands; on a curved one it does not, and the size of the miss is the floor.
That last test is the same one the shadow work uses on its receivers, and it is the cheapest thing in this essay: one extra mark, and the answer to whether any of the rest is needed.
The three levels, and the one that is a refusal
Written out, the answer has three levels of knowledge and they differ in kind rather than in degree.
Know the surface and the recovery is exact. No fitting, no residual, arithmetic only.
Know the shape but not its parameter and the error is proportional to the mistake, with a constant that can be measured and turned into a tolerance.
Know nothing and assume flat, and the error is the shape of the floor, exact at whatever was fitted and wrong everywhere else.
And there is a fourth level which is not a worse version of the third but a refusal. For a floor that cannot be unrolled — a dish, a dome, anything with curvature — there is no flat design to recover, because “the flat design that was painted on it” names nothing. A recovery computed through some chosen flattening of a dish returns the choice, not the design.
Which floors those are is decided by a single number, and it has nothing to do with how curved the floor looks.
Reads more easily once this is understood
Essays that name this one as worth reading first.
Shares its objects with
Essays that name at least two of the same things, and that neither author linked.
- How well the floor has to be known — both name developable, gaussian curvature, homography, least squares, ray tracing, rectification, single-view metrology
- The cone that reads the floor — both name anamorphosis, developable, homography, invertibility, projective map, ray tracing
- The floors that unroll — both name arc length, developable, gaussian curvature, isometry, picture plane, rectification
- A floor anamorph is three numbers — both name anamorphosis, homography, picture plane, projective map
- A projection of a projection — both name homography, picture plane, projective map, rectification
- Straightening does not move the eye — both name homography, picture plane, projective map, rectification
Named objects
A flat tag is an object no other essay names yet.
AnamorphosisArc lengthDevelopableGaussian curvatureHomographyInvertibilityIsometryleast squaresPicture planeProjective mapRay tracingre-projectionRectificationsingle-view metrology