The real instrument

A stack shot from one pupil is one picture scaled

A focus stack's exposures are seen from entrance pupils a focusing extension apart, 4.5 mm across twelve exposures of a room, so an occlusion edge's two sides come from different places and are 9.8′ out of register at the frame's edge. A rail that moves the camera back by each exposure's extension puts every pupil at one place, and then every exposure is the same central projection at a different image distance: the misregistration is gone at any count, and focus breathing becomes one magnification per exposure, the same at every depth, which a stacker takes out exactly. The rail must place each pupil to 0.7 mm to keep the edge inside the stack's own sharpness. What no rail touches is the halo, and stopping the far exposures down trades it deliberately: twelve exposures at half their pupils are sharper inside and cleaner at the edge than four at full.

Worth reading first: The eye is a place, not a point · The centre has an area.

A focus stack is sharp everywhere but its edges photographed a room from half a metre to four metres through a 50 mm lens in several exposures, each focused on its own slice of the room’s depth at the aperture that holds that slice best, and merged them by keeping every point from the exposure sharpest for it. On a continuous surface the stack was sharper than any single focus, more so with every exposure added, 1.52′ at twelve against one focus stopped down’s 5.3′. At an occlusion edge, where a near object stands in front of a far wall, it paid twice. The far exposures, shot wider open, blurred the near object’s edge over the wall behind it, a halo up to 11.3′ wide; and the two sides of the edge were taken from exposures whose entrance pupils sat a focusing extension apart, so they were seen from different places and out of register by up to 9.8′ at the frame’s edge.

The essay ended on a rig that would remove the second cost. A camera on a rail that moves backward by each exposure’s focusing extension, as the lens moves forward to focus, keeps every exposure’s pupil in one place. It asked how far that brings the edge’s misregistration down; whether the magnification each focus brings, which stacking software removes by scaling, is then the same for both sides of an edge and can be taken out exactly; and whether, with the parallax gone, the halo can be narrowed by choosing the far exposures’ apertures for the edge rather than for their own slice.

Where the pupils are

A rail that moves the camera back by each exposure's focusing extension puts all twelve entrance pupils at one placeThe twelve exposures of a stack of a room from 0.5 m to 4 m through a 50 mm lens, focused at 519 mm to 3097 mm. Focusing moves the lens, and its entrance pupil, forward by f²/(u − f): 0.82 mm for the farthest focus to 5.33 mm for the nearest, a spread of 4.51 mm (upper row). A rail that moves the whole camera back by each exposure's extension as it focuses leaves every pupil at the same place (lower row).camera stillcamera on the rail012345entrance pupil forward of where it starts (mm)12 exposures, 0.5 to 4 m, 50 mm lensdark: nearest and farthest focus
Fig. 1 The entrance pupils of the twelve exposures of a stack of the room, with the camera still and with the camera moved back on a rail by each exposure’s focusing extension.

The lens here focuses by moving as a whole, the way most prime lenses of this focal length do, and its entrance pupil goes with it. Focused at a distance uu, a 50 mm lens stands f2/(u−f)f^2/(u - f) forward of where it stands at infinity: 0.82 mm for the farthest of the twelve focuses, at 3.1 metres, and 5.33 mm for the nearest, at 0.52 metres. The twelve pupils are spread along the axis over 4.51 mm. Focusing is a zoom found that this extension also changes what the lens draws; here it matters because it moves the place the picture is taken from.

A rail under the camera that moves it back by each exposure’s extension, as the lens focuses, cancels that movement exactly: every pupil sits at one place, the one it occupied focused at infinity. The pictures are then all taken from one point, and the earlier essay’s misregistration has nothing to act on.

The edge, back in register

With every pupil at one place, the edge's misregistration is gone at any count; a rail off by δ brings back δ's share of itThe misregistration between an occlusion edge's two sides at the frame's edge, 19.8° off axis, for a near object at 0.5 m in front of a far wall at 4 m: without the rail (solid) it is tan θ times the spread of the pupils times the difference of reciprocal depths, 5.32′ for two exposures and 9.77′ for twelve. With an exact rail it is nothing at any count. A rail that places each pupil only to within δ leaves tan θ·δ·(1/0.5 m − 1/4 m): 0.22′ at 0.1 mm and 1.08′ at 0.5 mm (dashed).02.5057.501024681012exposures in the stackmisregistration at the frame's edge (′)no railexact railrail off 0.1 mmrail off 0.5 mmedge 0.5 m in front of 4 m19.8° off axis
Fig. 2 The misregistration between an occlusion edge’s two sides at the frame’s edge, without the rail, with an exact rail, and with a rail placing each pupil only to within 0.1 or 0.5 mm, against the number of exposures.

Without the rail, the edge between a near object at half a metre and the far wall behind it is out of register at the frame’s edge, 19.8° off axis, by the tangent of that angle times the spread of the pupils times the difference of the reciprocal depths: 5.32′ for two exposures and 9.77′ for twelve, growing with the count as the pupils spread further. With an exact rail it is nothing at any count. Both sides of the edge are seen from one point, so they stand in the picture exactly where a single exposure would put them, whichever exposures they were taken from.

The answer to the first question is that the rail removes the misregistration entirely, not most of it. The earlier essay expected one term to remain, the walk of the entrance pupil with field angle that the entrance pupil walks with the angle measured, since no rail can make a pupil sit at one place for every angle at once. For a lens that focuses as a whole, that walk is the same in every exposure: the pupil for a ray at 15° sits at the same place relative to the lens whatever the lens is focused on, and the rail, which moves the whole lens, moves that place with it. Every exposure then has the same pupil at every angle, walking or not, and the walk cancels between exposures as completely as the extension does. It would not cancel for a lens that focuses by moving an internal group, whose pupil walk changes with focus; that case is left at the end.

The contrast with a panorama is instructive, since the same rail appeared there first. A refocused panorama is six lenses slid the camera back on its head by each frame’s extension as the lens refocused between frames, and was left with 2.82′ along its worst seam, the lens’s walk alone. A panorama’s frames point in different directions, so one point of the room is seen at one field angle in one frame and at another in the next, and the walk, which depends on the angle, puts the pupil at different places for the two. A stack’s exposures all point the same way. One point of the room is at the same field angle in every exposure, the walk puts the pupil at the same place for it in every exposure, and nothing is left. The rail that could only bring a panorama down to its lens’s walk brings a stack all the way to zero.

A rail is not exact. It places each pupil to within some tolerance, and whatever it misses reopens the parallax in proportion: 0.22′ for a rail off by a tenth of a millimetre, 1.08′ for half a millimetre.

To keep the edge within the stack's own sharpness, the rail must place every pupil to 0.7 mmThe misregistration a rail's position error leaves at the frame's edge, 2.17′ per millimetre, against the twelve-exposure stack's own worst blur on a continuous surface, 1.52′ (dashed). They cross at 0.70 mm: a rail placing each pupil more finely than that keeps the edge's two sides in register to within the stack's sharpness; one coarser reopens a fraction of the 9.77′ it was built to remove.01200.2000.4000.6000.8001rail's error in placing each pupil (mm)misregistration at the frame's edge (′)the stack's own floor12 exposures, 19.8° off axiscrossing at 0.70 mm
Fig. 3 The misregistration a rail’s position error leaves at the frame’s edge, against the twelve-exposure stack’s own worst blur on a continuous surface. The slider sets the rail’s error.

The residual is 2.17′ for every millimetre of rail error, and the stack’s own worst blur on a continuous surface is 1.52′. They cross at 0.70 mm. A rail that places each exposure’s pupil to better than seven tenths of a millimetre keeps the edge’s two sides in register to within the sharpness the stack achieves anyway; one coarser reopens a share of the 9.77′ it was built to remove. Seven tenths of a millimetre is an ordinary tolerance for a motorised focusing rail, which is built for macro work to steps of a few hundredths, but it is not an ordinary tolerance for a rail moved by hand against a scale.

Breathing, taken out exactly

The second question was about magnification. Every exposure of a stack is magnified differently, since the lens stands at a different distance from the sensor at each focus, and a stacker aligns the exposures by scaling each to a common size before merging. The question was whether one scale per exposure aligns both sides of an edge.

With the rail, each exposure's focus breathing is one magnification for every depth; without it, near and far breathe differentlyThe magnification of each exposure's picture against the farthest-focused one's. With the rail (solid), every pupil at one place, it is the focal length plus that exposure's extension over the same sum for the farthest focus, for every depth alike: 1.0888 for the nearest focus, falling to 1. Without the rail, an object at 0.5 m (dashed) is magnified 1.0987 in the nearest-focused exposure and an object at 4 m (dotted) 1.0900: a stacker that scales each exposure by one number aligns one depth and leaves the other 0.80% out.11.021.051.071.1002.5057.5010exposure, nearest focus firstmagnification against the farthest focusrail, any depthno rail, at 0.5 mno rail, at 4 m12 exposures, 50 mm lensrelative to the farthest focus
Fig. 4 Each exposure’s magnification against the farthest-focused one’s: with the rail, the same at every depth; without it, for an object at 0.5 m and at 4 m.

With the rail, every exposure is the same central projection from the same point, recorded on a sensor at a different distance behind it, ff plus that exposure’s extension. A picture recorded at a different distance from the same point is the same picture scaled about its centre, every point by the same factor whatever its depth: (f+ek)/(f+efar)(f + e_k)/(f + e_{\text{far}}), 1.0888 for the nearest-focused exposure against the farthest. One scale per exposure aligns the whole picture, near objects and far ones, and the scale is known in advance from the focus.

Without the rail the exposures are not one projection. The nearest-focused exposure magnifies an object at half a metre by 1.0987 and one at four metres by 1.0900, because its pupil is 4.5 mm nearer the near object, a larger share of its distance. A stacker that scales each exposure by one number can align one depth and leaves the other 0.80% out, which at the frame’s edge is the misregistration again, read as a magnification. So the second answer is yes, and it is what makes the first answer usable: with every pupil at one place, breathing stops being a depth-dependent distortion and becomes one known number per exposure.

One point, one picture

The two answers are one fact about projections, and it is worth stating because it is the reason the rail is worth building rather than a refinement of the software. A picture taken through a pinhole is fixed, up to its scale and its placing on the sensor, by where the pinhole is and which way it looks. Twelve exposures from one point, all looking the same way, are one picture twelve times, differing only in scale: any one of them can be mapped onto any other by a single scaling about the centre, which a stacker can apply without knowing anything about the scene. Twelve exposures from twelve points along the axis are twelve different pictures. No mapping of the picture alone carries one onto another, because how far a point moves between them depends on how far away it is, and the picture does not say that. A stacker aligning such exposures has to choose a depth to align at, and every other depth is left out of register by its distance from that one.

That is why the rail is a better answer than any amount of alignment after the fact. Alignment can only choose which depth to get right; the rail makes the choice unnecessary, by making the exposures one picture before they are taken.

The rail has one side effect worth planning for. Moving the camera back by an exposure’s extension moves its plane of focus back by the same amount, since the lens now stands where it stood focused at infinity: 5.33 mm at the nearest focus, about a seventh of a slice of the room’s reciprocal depth at that distance, and less than a thousandth of a slice at the farthest. A stack planned for a rail focuses each exposure that much further out, so that its slice lands where it was meant to; one that does not shifts its near slices slightly toward the camera, by an amount small against a slice at twelve exposures and larger against the thicker slices of a short stack; what that costs in sharpness was not measured here.

The halo, chosen

The rail leaves the halo where it was. The halo is the far exposures’ blur of the near object, and it depends on how wide open those exposures are and on nothing about where they are taken from. The third question was whether, with the parallax gone, the far exposures’ apertures can be chosen for the edge instead of for their own slice.

More exposures with their far pupils stopped down beat fewer exposures at their own pupils, on the edge and the interior at onceEach stack placed by its worst blur on a continuous surface (across) and its halo beside an occlusion edge (up). Stacks of 2, 4, 8, 12, 16 exposures, every exposure at the pupil best for its own slice (dots): 2: 3.73′, 4.16′; 4: 2.63′, 6.58′; 8: 1.86′, 8.58′; 12: 1.52′, 11.29′; 16: 1.32′, 12.57′. Twelve and sixteen exposures with the far half stopped down to a fraction of that pupil (lines, from full to 0.3): twelve at half the pupil reach 2.22′ and 4.70′, sharper inside and with a narrower halo than four exposures at full pupils, 2.63′ and 6.58′.05101234worst blur on a continuous surface (′)halo beside the edge (′)248121612, far half stopped16, far half stoppedfull pupils, by countroom 0.5 to 4 m, 50 mm lenslower and further left is better
Fig. 5 Stacks placed by their worst blur on a continuous surface and their halo beside an occlusion edge: stacks of two to sixteen exposures at their own best pupils, and twelve and sixteen exposures with the far half stopped down.

Every stack in the earlier essay chose each exposure’s pupil to hold its own slice best, and the stacks it produced lie along a line in this figure: more exposures, sharper inside and wider halo. Two exposures, 3.73′ inside and a 4.16′ halo; four, 2.63′ and 6.58′; eight, 1.86′ and 8.58′; twelve, 1.52′ and 11.29′; sixteen, 1.32′ and 12.57′. A photographer choosing a count is choosing a point on that line.

Stopping the far half of the exposures down moves a stack off the line. Twelve exposures with their far six at half the pupil best for their slices are 2.22′ inside, with a 4.70′ halo: sharper inside than four exposures at full pupils, and with a narrower halo. Sixteen exposures stopped down the same way do slightly better again. Every point of the twelve- and sixteen-exposure curves below the full-pupil line is a stack that beats a stack of fewer exposures on both counts at once.

The reason is in where each cost comes from. The interior blur of a stack is set by how thin each slice is and how well each exposure holds its own; stopping an exposure down blurs its slice’s ends by diffraction, but a thin slice has little depth to hold and loses little. The halo is set only by how wide the far exposures are open, which stopping down narrows in proportion. A thick slice at full pupil and a thin slice stopped down can have the same interior blur, and the thin one has the narrower halo. More exposures buy thinner slices; stopping the far ones down spends some of that on the edge.

In f-numbers the change is small to make. Each of the twelve exposures is shot at f/11.7, the aperture that holds a twelfth of the room’s reciprocal depth best; the far six are shot instead at f/23, two stops down, and the near six are left where they were. The stack takes the same twelve exposures and the same time, and its halo narrows from 11.3′ to 4.7′ while its interior blur rises from 1.52′ to 2.22′, still the sharpness of a stack of five or six at full pupils.

So the third answer is yes, and the trade is deliberate in exactly the sense the earlier essay hoped. A stack’s interior sharpness and its edge are not tied by the count alone. With the parallax gone, so that the far exposures’ only cost at the edge is their halo, the photographer can choose how much interior sharpness to give up for a cleaner edge, and pays for it in exposures rather than in either quality.

The rig and the lens, as modelled

The lens is thin and focuses as a whole. Its entrance pupil sits at the lens and moves with it, which the hole a scene actually sees is the reminder is an idealisation: a real pupil is an image of the stop, somewhere in the lens, but for a lens that moves as a unit it moves by the same extension and the rail’s arithmetic is the same.

Each exposure’s pupil is the one that holds its slice best, as in the earlier essays, and stopping down scales it by a stated fraction. A real lens’s apertures come in steps; a third-stop step is a factor of 0.89 on the pupil.

The edge is a near object at half a metre in front of a far wall at four, the two extremes of the room, which is where both the misregistration and the halo are worst; an edge between nearer depths costs less of each.

Merging keeps each point from its sharpest clean exposure and does nothing cleverer at the edge. A stacker that reconstructs the far wall behind the near object’s blur from the near-focused exposures’ views, which a pupil sees around an edge found possible in principle, would narrow the halo without stopping down.

Still open: whether a lens that focuses internally can be railed

Every exposure here comes from a lens that focuses by moving as a whole, so a rail that undoes its movement undoes every change in where its pupil sits. Many modern lenses focus by moving a group of elements inside the barrel. Their length does not change, their entrance pupil moves by an amount that is not the focusing extension, and their focal length changes with focus as well, which focusing moves the pivot past its best place met when a panorama was refocused.

The measurement that settles what a rail can do for such a lens takes an internal-focus design with a stated pupil position and focal length at each focus, finds the rail position for each exposure that puts its pupil on axis at one place, and asks how much misregistration the pupil’s walk with field angle then leaves, since that walk now changes between exposures and no single rail position can match it at every angle; and whether the residual, for lenses of the kind used for stacking, stays under a stack’s own blur or reopens most of the earlier essay’s 9.8′.

A lens that focuses behind its stop needs no rail takes that measurement: the entrance pupil is the stop seen through the elements in front of it, so a lens focusing behind its stop keeps its pupil and its walk still and needs no rail, while one focusing in front of its stop moves both, and a rail placing its paraxial pupil leaves a sixth of the misregistration, 0.73′, or 0.19′ aimed at the pupil for 17°.

A focus stack’s exposures are taken from pupils a focusing extension apart, so an occlusion edge’s two sides are out of register at the frame’s edge. A rail that moves the camera back by each extension puts every pupil at one place: every exposure is then the same central projection at a different image distance, the misregistration is gone at any count, and focus breathing is one known magnification per exposure, the same at every depth. The rail must place each pupil to about 0.7 mm. The halo is the aperture’s alone, and stopping the far exposures down trades it deliberately: twelve exposures at half their pupils beat four at full, inside and at the edge.

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.

depth of fieldEntrance pupilinstrument limitOcclusionParallaxThin lens