Through water and glass

A wedge moves the centre, not the lens

A wedge of glass in front of a lens deflects every ray by a little more the further off the axis it goes, which looks like the shape a radial distortion coefficient describes. Fitted together, the two are nearly independent — correlated at 0.16 at most — and a calibration that knows nothing of the glass does not invent a lens: it reports a coefficient of about 0.002, moves its principal point by 4.5 to 14 pixels, and leaves a swirling residual that no radial model takes. The blame goes to the camera's centre, and the residual says so from twenty-two degrees off the axis.

Worth reading first: What survives a pane of glass · Recovering the camera from the picture it drew.

The wedge recovered with the camera put a wedge of glass into the camera model and recovered its angle from directions spread far enough off the axis: nothing inside eighteen degrees, a tenth of a degree by fifty-five. It closed on a concern about what else a real picture contains. A real camera has a lens with distortion of its own, and the wedge and the lens are fitted from the same picture.

The concern was specific. A wedge’s leading effect is a turn of every ray, which the camera’s orientation absorbs. Its next effect is a deflection that grows with the angle off the axis — and a displacement that grows with the angle off the axis is what a radial distortion coefficient describes. So the worry was that the two parameters would compete for one part of the signal, and that a calibration done through a display case would return a distorted lens that does not exist, with nothing in its residual to say so.

The measurement refuses both halves of that worry and finds a different victim.

Two models fitted together are nearly independent

The arrangement extends the earlier one in two ways. The camera now has a lens with a radial coefficient k1k_1, bending each projected point outward or inward by 1+k1r21 + k_1 r^2 in the radius rr measured in focal lengths. And the world directions are read on two rings, one at the stated angle off the axis and one at half of it, six directions on each, so that a radial coefficient has two radii to be told from a change of scale by. A 2° wedge of crown glass, its thick edge turned 25° from the picture’s horizontal, sits in front; the focal length is 620 px.

Fitted together, the wedge's angle and the lens's coefficient are correlated at -0.16 at mostThe camera's rotation, a 2° wedge's angle and azimuth, and the lens's radial coefficient fitted together from twelve directions on two rings, and the correlation between the wedge angle and the coefficient in the fit's covariance, against how far off the axis the outer ring reaches. It runs -0.148 at 10°, -0.108 at 18°, -0.096 at 25°, -0.095 at 32°, -0.107 at 40°, -0.138 at 50°, -0.155 at 55°: within 0.16 of zero everywhere. Near-perfect competition would sit at ±1. The two parameters are not fighting over one part of the signal; what limits each is how far the reading reaches, not the other.-1-0.50000.50011020304050how far off the axis the reading reaches, degreescorrelation of wedge angle and k₁ in the joint fitfully tradedmeasuredjoint fit, two rings of six directions|r| ≤ 0.16
Fig. 1 The camera’s rotation, the wedge’s angle and azimuth and the lens’s radial coefficient fitted together, and the correlation between the wedge angle and the coefficient, against how far off the axis the outer ring reaches. It stays between −0.09 and −0.16 at every reach; full competition would be ±1.

Fitted with everything free — three numbers of rotation, the wedge’s angle and azimuth, and k1k_1 — from exact readings, the fit returns the wedge and the lens exactly. The question is how the two trade under error, and the fit’s own covariance answers it: the correlation between the wedge’s angle and k1k_1 is −0.148 when the reading reaches ten degrees, −0.095 at thirty-two and −0.155 at fifty-five. A correlation near ±1 is what two parameters look like when one can stand in for the other; these are near zero at every reach.

The reason is the shape of the two displacements rather than their size. A radial coefficient moves every point along the line to the centre, by an amount that depends on its distance from the centre and on nothing else. A wedge moves points by an amount that depends on which way they lie relative to its thick edge: rays heading toward the thick edge meet the glass at a different angle from rays heading away from it. The two patterns overlap only in their average outward component, and that is a small part of either.

A calibration that knows nothing of the glass

The case the earlier essay worried about is the one where the glass is not in the model at all. A calibration of the usual kind fits the camera’s rotation, the radial coefficient, the focal length and the principal point, and has no parameter for a wedge.

Through a 2° wedge, a calibration with no glass in it leaves 1.62 px that no lens coefficient takesTwelve directions on two rings, 40° and 20° off the axis, seen through a 2° wedge by a camera whose lens has no distortion, and fitted by a calibration that knows nothing of the glass: the camera's rotation, a radial coefficient, the focal length and the principal point all free. The large dots are the twelve readings; the arrows are the difference between where the glass puts each direction and where the calibration puts it, drawn over the whole disc the readings span and magnified 40 times, at 0.252 of the picture's scale. At the readings it leaves 1.615 px root-mean-square and 3.42 px at worst; across the disc, up to 3.62 px. It has moved its principal point by 7.75 px and reported a radial coefficient of 0.00152. The pattern is not radial — it swirls with the wedge's thick edge — which is why no radial coefficient takes it. The same readings with the wedge in the model leave 9e-14 px.residual × 40 · rms 1.62 px at the readings · principal point moved 7.7 pxno single viewpoint — the rays miss by a wedge's worth, varying with incidencethe glass-blind calibration at 40°
Fig. 2 What a calibration with no glass in it leaves, through a 2° wedge, read to 40° off the axis: the twelve readings as large dots and the residual over the whole disc as arrows, forty times actual size. 1.62 px at the readings, swirling rather than radial; the principal point has moved 7.7 px. The slider changes how far the reading reaches.

The figure shows what it leaves, for a lens with no distortion behind a 2° wedge, read out to forty degrees. The twelve readings are drawn as large dots; the arrows are the difference between where the glass puts each direction and where the calibration puts it, drawn over the whole disc and magnified forty times. At the readings the calibration leaves 1.615 px root-mean-square and 3.42 px at worst. The pattern is two vortices either side of a line through the centre — a swirl set by the wedge’s thick edge — and nothing about it is radial.

A 2° wedge adds 0.0021 to 0.0062 to the radial coefficient a calibration reportsThe radial coefficient a calibration reports when it fits the camera's rotation, the coefficient, the focal length and the principal point but knows nothing of a 2° wedge in front of the lens, less the lens's own. For a lens with no distortion it reports 0.0062 at 10°, 0.0025 at 18°, 0.0018 at 25°, 0.0015 at 32°, 0.0015 at 40°, 0.0018 at 50°, 0.0021 at 55° — a trace of pincushion that is largest where the reading is narrowest. For a lens with a coefficient of −0.08 it reports -0.0718, -0.0767, -0.0777, -0.0780, -0.0780, -0.0775, -0.0770, out by 0.0020 to 0.0082. Through no glass it returns −0.08 at every reach. A wedge is not read as a lens that does not exist; it is read as a lens very slightly less barrelled than the one there is.00.0020.0040.0060.0081020304050how far off the axis the reading reaches, degreesradial coefficient reported, less the lens's owna lens with nonea lens at −0.08rotation, k₁, focal length and principal point fittedthrough no glass: 0 exactly
Fig. 3 The radial coefficient a glass-blind calibration reports, less the lens’s own, against the reach. For a lens with no distortion it reports 0.0062 at 10° falling to 0.0015 by 32°; for a lens at −0.08 it is out by 0.0020 to 0.0082. Through no glass it returns the lens’s own coefficient exactly.

The coefficient it reports is small. For a lens with no distortion at all, the calibration finds k1=0.0062k_1 = 0.0062 when the reading reaches ten degrees, 0.0025 at eighteen and 0.0015 from thirty-two on — a trace of pincushion, largest where the reading is narrowest. For a lens with a genuine barrel coefficient of −0.08, it reports −0.0718 to −0.0780: a lens very slightly less barrelled than the real one, not a lens that does not exist. Through no glass the same calibration returns −0.08 at every reach, which is the control.

So a display case does not make a calibration report a strongly distorted lens. It makes the lens read about two per cent less distorted than it is, and it does something else with the rest of the wedge.

The blame goes to the principal point

The wedge’s effect has to go somewhere, and the calibration has four places to put it.

A glass-blind calibration moves its principal point 4.5 to 14.4 pxHow far a calibration that does not model a 2° wedge moves its principal point from the true centre, against how far off the axis its reading reaches: 4.53 px at 10°, 4.65 px at 18°, 5.19 px at 25°, 6.10 px at 32°, 7.75 px at 40°, 11.39 px at 50°, 14.42 px at 55°, in a direction between -69° and -66° on the picture. Its focal length moves by 0.28 per cent at most. The wedge's leading effect is a turn of every ray, which the camera's rotation takes; what the rotation cannot take is shared between the principal point and the residual, and very little of it goes to the radial coefficient.0510151020304050how far off the axis the reading reaches, degreesprincipal point moved, pxrotation, k₁, focal length and principal point fitted14.4 px at 55°
Fig. 4 How far the glass-blind calibration moves its principal point from the true centre, against the reach: 4.53 px at 10°, 7.75 px at 40° and 14.42 px at 55°, always in nearly the same direction on the picture. The focal length moves by 0.28 per cent at most.

The rotation takes the wedge’s leading effect, the uniform turn of every ray, as it did when there was no lens. What the rotation cannot take goes mostly to the principal point: the calibration moves it by 4.53 px when the reading reaches ten degrees, 7.75 px at forty and 14.42 px at fifty-five, always in nearly the same direction on the picture, between −69° and −66°. The focal length moves by 0.28 per cent at most, and k1k_1, as above, barely at all.

That is the answer to “the wedge or the lens” — neither. The calibration blames the camera’s centre. A principal point moved by several pixels is a plausible calibration result: the principal point is not the centre measured how far a cropped or shifted frame’s principal point sits from the middle, and a calibration reporting a centre five pixels off is not reporting anything alarming. The wedge hides there.

A tilted sensor is not a distortion found the same place used by a different departure: a sensor tilted out of square with its lens moves every point of the picture, keeps straight lines straight, and is an ordinary pinhole picture whose principal point has moved — absorbed exactly by a calibration that frees its principal point. A wedge is not absorbed exactly, because it is not a pinhole picture at all, but the calibration reaches for the same parameter first. The principal point is where a calibration puts whatever moves the picture without being radial.

The residual announces it

The earlier worry had a second half: that nothing in the residual would say the model was wrong. The residual does say so, once the reading is spread.

The glass-blind calibration's residual passes a 0.4 px reading error at 22° and grows as the reading spreadsThe root-mean-square residual a calibration leaves when a 2° wedge sits in front of a lens with no distortion and the calibration does not model it, against how far off the axis the reading reaches. With the rotation and a radial coefficient free it is 0.084 px at 10°, 0.277 px at 18°, 0.581 px at 25°, 1.083 px at 32°, 2.069 px at 40°, 4.549 px at 50°, 6.815 px at 55°; freeing the focal length and the principal point as well lowers it to 0.073, 0.239, 0.492, 0.889, 1.615, 3.274, 4.694 px. A reading error of 0.4 px is passed at about 22°. Below that the wedge hides in the reading error; above it no radial model absorbs it, and the calibration's own residual says there is something it cannot fit.0.10.3131020304050how far off the axis the reading reaches, degreesresidual left, px rms (log scale)a reading error of 0.4 pxrotation and k₁and focal, centrea 2° wedge, a lens with no distortionpasses 0.4 px at 22°
Fig. 5 The residual the glass-blind calibration leaves, root-mean-square, against the reach, with the rotation and radial coefficient free and with the focal length and principal point freed as well. It passes a 0.4 px reading error at about 22° and reaches 4.7 px at 55°.

With only the rotation and the radial coefficient free, the calibration leaves 0.084 px root-mean-square when the reading reaches ten degrees, 0.58 px at twenty-five, 2.07 px at forty and 6.8 px at fifty-five. Freeing the focal length and the principal point lowers that to 0.073, 0.49, 1.62 and 4.7 px: the extra parameters take something, but far from all of it. Against a reading error of 0.4 px, the residual passes the reading error at about twenty-two degrees.

So there are two regimes, and the boundary between them is roughly where the wedge recovered with the camera found the wedge’s angle first becoming recoverable. Inside about twenty degrees, the wedge is invisible to a calibration that does not model it: the residual is within the reading error, the principal point is quietly several pixels out, and the rotation carries most of the glass’s deviation of about a degree. Outside it, the residual grows faster than the reach, and its pattern — the swirl in the hero figure, not a radial one — is a signature a careful reader can recognise. A calibration report with a residual several times its reading error and a principal point pushed off in one direction is reporting glass.

Fitted together, neither pays for the other

With both in the model, the question left is how well each is known under a real reading error.

Fitted together at 0.4 px, the wedge's angle is known to 0.031° and k₁ to 0.00009 at 55°One standard deviation of the wedge's angle, in degrees, and of the lens's radial coefficient, times a hundred, when both are fitted with the camera's rotation from twelve directions read to 0.4 px, against how far off the axis the reading reaches. The angle goes from 1.93° at 10° to 0.031° at 55°; the coefficient from 0.0496 to 0.00009. Both fall together as the reading spreads, which is what nearly independent parameters do; neither is bought at the other's expense.0.010.030.10.3131020304050how far off the axis the reading reaches, degreesone standard deviation (log scale)wedge angle, degreesk₁ × 100joint fit, 0.4 px reading errorboth fall together
Fig. 6 One standard deviation of the wedge’s angle and of the lens’s radial coefficient, fitted together from twelve directions read to 0.4 px, against the reach. The angle falls from 1.93° at 10° to 0.031° at 55°; the coefficient from 0.050 to 0.00009. Both fall together.

At a reading error of 0.4 px, the wedge’s angle is known to 1.93° when the reading reaches only ten degrees — its whole value, nothing recovered — and to 0.031° at fifty-five. The radial coefficient is known to 0.050 at ten degrees and 0.00009 at fifty-five. Both fall together as the reading spreads, and neither falls more slowly because the other is being fitted. That is what the correlation near zero predicts: each parameter’s precision is set by how far the reading reaches, and freeing the other costs almost nothing.

The practical reading follows directly. A calibration through glass that can be modelled — a display case, a port in a housing, a windscreen — gains the glass’s two numbers without losing precision on the lens, provided the reading reaches past the twenty-odd degrees where the glass first shows. Inside that, neither the glass nor the principal point is trustworthy, and adding the glass to the model does not help, because there is nothing in the reading to separate the glass from a turn of the camera and a shift of its centre.

What a reading through glass has to reach

The measurements above turn into a short protocol for anyone calibrating through a window, and each step rests on a number from them.

First, the reading has to reach past about twenty-two degrees off the axis, or the glass cannot be seen at all: inside that, its whole effect is shared between a turn of the camera and a shift of the principal point, and the residual stays within a 0.4 px reading error. That is the same boundary the wedge recovered with the camera found for recovering the wedge’s angle, arrived at from the calibration’s side. A narrow lens behind a display case therefore cannot tell whether the glass is there, and a calibration of it will report a principal point several pixels off with nothing to say why.

Second, a flat pane is not a wedge and does not do any of this. What survives a pane of glass found that a slab with parallel faces moves no direction at all, and a pane gives a product before it gives two numbers that what a pane does to positions depends on its thickness and index only together. The swirl in the hero figure is the signature of faces that are not parallel; a calibration through an ordinary window, whose faces are parallel to a small fraction of a degree, sees a correspondingly small version of it.

Third, the principal point is the parameter to watch. A calibration’s principal point is usually reported and rarely questioned, and a few pixels off the middle of the frame is ordinary. Through a wedge, a few pixels off in one fixed direction, together with a residual several times the reading error, is the combination that identifies glass, and neither half alone does.

A second route to the centre

There is a way to catch the glass with no extra parameter, and it uses the oldest recovery a picture offers.

Recovering the camera reads the principal point out of a picture from the vanishing points of three perpendicular families of edges: the principal point is where the triangle of vanishing points has its altitudes meet. That reading uses directions, as the calibration here does, but it has no radial coefficient and no freedom to trade the principal point against anything; the three vanishing points fix it. Through a wedge, the vanishing points are themselves deflected, each by an amount depending on its direction relative to the thick edge, so the principal point that construction returns is also moved — but by a different amount from the calibration’s, because the two readings use different directions and different models.

So two readings of one camera’s centre, taken through the same glass by two routes, disagree, where through no glass they would agree. That disagreement is a test for glass that needs nothing but the picture. How large it is for a 2° wedge, and how far the vanishing points must lie off the axis for it to exceed their own reading error, was not measured here; it is the kind of cross-check a recovery from vanishing points exists to allow. A calibration target and a building’s edges seen through the same window, read separately, would give it for free, and a disagreement of a few pixels in their centres would be the glass’s signature in a form nobody has to go looking for.

Why the shapes are different

The wedge’s deflection is often described in one line: (n−1)α(n - 1)\alpha for a ray along the axis, growing off the axis. That line hides the part that matters here.

A ray crossing a wedge is deflected in the plane that contains it and the wedge’s thickness gradient, and by an amount that depends on its angle of incidence at each face. Two rays at the same angle off the axis but on opposite sides — one heading toward the thick edge, one away — meet the first face at the same angle but the second face at different ones, and are deflected by different amounts. So the deflection has a component that changes sign across the line perpendicular to the thick edge, and that component is what turns into the two vortices of the hero figure once the uniform part has been taken by the camera’s rotation.

A radial coefficient has no such component. It is symmetric about the centre by construction, and straight lines that are not used that symmetry to show that a radial map leaves exactly the lines through the centre straight. A wedge leaves no family of lines straight in general, and its departure from a turn is antisymmetric about a line rather than symmetric about a point. The two can only share their average outward push, which is why the correlation stays near zero.

What this leaves out

Tangential terms. The calibration here has one radial coefficient. Many calibrations add decentring terms, which are not radially symmetric, and those may take more of the wedge’s swirl than the principal point does. A tilted sensor is not a distortion found that such terms describe a change of camera badly; whether they describe a wedge better was not measured.

A thin wedge and a thick one. Every number is for a 2° wedge of crown glass. The deflection is nearly proportional to (n−1)α(n - 1)\alpha at small angles, so the principal-point shift and the residual should scale with it; if they do, a display case with faces a quarter of a degree out of parallel moves the principal point by about half a pixel. That scaling was not measured.

A planar target. The readings are world directions, as in the earlier essays, standing for the vanishing points of straight edges. A calibration from a flat checkerboard seen at several poses reads positions rather than directions, and its extrinsics may take a different share of the wedge.

Still open: whether decentring terms take the swirl

The calibration here chose among a rotation, a radial coefficient, a focal length and a principal point, and gave most of the wedge to the principal point and the residual. Standard calibrations have two more parameters for exactly the kind of displacement a radial coefficient cannot describe: the decentring, or tangential, terms, which model a lens whose elements are not quite coaxial.

A wedge in front of a lens is, loosely, a very badly decentred element, and the measurement that settles the question refits the glass-blind calibration with the two decentring terms free and asks three things: how much of the swirl they absorb, whether the principal point then moves less, and whether the decentring terms a glass-blind calibration reports are large enough to look like a defective lens. If they take most of it, a calibration through glass returns a lens that is plausibly misassembled rather than a principal point that is plausibly off, and the residual that announced the glass here goes quiet.

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 calibrationConditioningIdentifiabilityleast squaresModel errorRadial distortionRefractive indexResidualSnell's law