The real instrument

A focus stack is sharp everywhere but its edges

Split a room half a metre to four metres deep into n slices of reciprocal distance, shoot one exposure on each at the aperture that holds its slice best, and keep each point from its sharpest exposure: every continuous surface is then held to √(2.44λΔ/n), 3.73′ for two exposures and 1.52′ for twelve, against one stopped-down focus's 5.27′, with seams between slices a quarter of that. The price is paid where a near object stands in front of a far one. The far exposures are shot wider open, so they blur the table across more of the wall, from 2.6′ at one focus to 11.3′ at twelve, and the table and wall come from different pupils, misregistered by up to 9.8′ at the frame's edge.

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

One focus stopped down is as sharp as six in a deep room found a floor that no lens can get under. A frame that holds everything from a table half a metre away to a wall at four metres can be held, at one focus, no sharper than 2.44λΔ\sqrt{2.44\lambda\Delta} radians, where Δ\Delta is the span of reciprocal distance the frame holds and λ\lambda the wavelength. For that room and green light the floor is 5.27 arcminutes, reached at whatever f-number gives an entrance pupil, the hole a scene actually sees, 1.24 mm across: f/40 on a fifty-millimetre lens. Defocus shrinks as the pupil closes and diffraction grows, and the floor is where they meet. No focal length appears in it.

The essay ended on the one strategy that escapes the floor by not asking one focus to hold the room. Focus stacking shoots the same frame several times at several focuses, each wide enough to avoid diffraction, and merges the sharp part of each. The essay proposed splitting the reciprocal depth into nn equal slices, giving each its own focus and the aperture that holds that slice best, so that the stacked frame’s worst blur would be the slice’s floor, 2.44λΔ/n\sqrt{2.44\lambda\Delta/n}. Against that it set a cost: each exposure’s pupil sits at its own focusing extension, so neighbouring slices see the scene from slightly different places. It asked how many slices make the stack sharper than one focus before the disagreement between slices becomes the larger error.

The first half is right and the second asked about the wrong boundary. Neighbouring slices barely disagree. What a stack pays for is the boundary between the first slice and the last, which a frame meets wherever something near stands in front of something far.

A stack of n exposures reaches the slice’s floor

The lens is the earlier fifty, the frame the table’s: half a metre to four metres, a reciprocal span of 1.75 per metre. A stack of nn splits that span into nn equal slices, focuses one exposure on the middle of each and stops it to the pupil that holds that slice best. The merge keeps each point from whichever exposure is sharpest for its distance.

Stacked from 4 exposures, a room half a metre to four metres deep is held to 2.63′ where one focus holds it to 5.27′The blur of a point against one over its distance, for a fifty-millimetre lens on the room from 0.5 m to 4 m. One focus at 0.889 m stopped to f/40 (dashed) holds the whole depth to 5.27′, a V with both ends at that height. A stack splits the depth into 4 equal slices of reciprocal distance and focuses one exposure on the middle of each at the aperture that holds that slice best, f/20.2 (thin), keeping each point from the exposure sharpest for it (thick): every depth is then held to 2.63′, the square root of 2.44 times the wavelength times the slice's depth. The slider changes the number of exposures.05100.50011.502one over the distance (1/m)blur (arcminutes)stack of 4each exposureone focus, f/400.5 m to 4 m, green light4 at f/20.2: 2.63′
Fig. 1 Blur against one over the distance for the room from half a metre to four metres: one focus stopped to f/40, each exposure of a stack, and the stack’s envelope. The slider changes the number of exposures.

Each exposure draws the earlier essay’s V, blur against reciprocal distance with its point at the exposure’s focus, and a narrower slice lets each V open its pupil wider before diffraction catches it. The merged frame follows the lowest V at every depth, so its worst blur is where two neighbouring Vs cross, at the slice boundaries, and that is the slice’s own floor. With four exposures at f/20.2 every depth in the room is held to 2.63 arcminutes, half of one focus’s 5.27.

On a continuous surface the stack's blur falls as one over the root of the count, and its seams stay far below itThe worst blur of the stacked room on a continuous surface (solid, dots), against the closed form √(2.44λΔ/n) (dotted): 5.27′ for one exposure, 3.73′ for two, 2.63′ for four at f/20.2, 1.52′ for twelve at f/11.7. The dashed curve is the worst seam where the stacker switches from one exposure to the next, at the edge of the frame, 19.8° off the axis: neighbouring exposures' pupils sit a slice's extension apart, and aligned at the room's harmonic middle they disagree by at most 0.70′ at any count, about a quarter of the stack's own blur.02462.5057.5010exposures in the stackarcminutesstacked blur√(2.44λΔ/n)seam between slicesa continuous surface, 0.5 m to 4 mtwelve: 1.52′
Fig. 2 The worst stacked blur on a continuous surface against the number of exposures, with the closed form 2.44λΔ/n\sqrt{2.44\lambda\Delta/n}, and the worst seam between neighbouring exposures at the frame’s edge.

Measured over the room, the stack’s worst blur matches the closed form at every count: 3.73 arcminutes for two exposures, 2.63 for four, 1.52 for twelve at f/11.7. It falls as one over the square root of the count, so halving the blur costs four times the exposures. The f-number falls as the square root too, so a twelve-exposure stack is shot three and a half stops wider than one focus, and each exposure needs about a twelfth of the time.

The seam the essay worried about is small. At a slice boundary the merge switches from one exposure to the next, and their pupils sit apart by the difference of their focusing extensions, the shift focusing moves the pivot past its best place measured for a panorama, f2/(u−f)f^2/(u - f) at each focus. The two exposures then disagree about where a point at the boundary’s depth lies by the tangent of its field angle times that pupil difference times its reciprocal distance from the depth the merge aligned the exposures at, taken here as the room’s middle. At the frame’s edge, 19.8° off the axis, the worst such seam is 0.70 arcminutes at any count, about a quarter of the stack’s own blur. Neighbouring slices differ in focus by a slice and in pupil by a slice’s extension, and both shrink together as the count grows.

So on a continuous surface, a floor running back from the table or a wall seen at a slant, a stack does exactly what the essay hoped. It is sharper than one focus with two exposures and keeps getting sharper, and its seams never come near its blur.

An occlusion edge meets the first slice and the last

A frame of a room is not a continuous surface. The table stands in front of the wall, and at the table’s edge the frame jumps from half a metre to four metres without passing through anything between. The merge then takes the table from the exposure focused nearest and the wall beside it from the exposure focused farthest, and those are the two exposures that differ most: by the whole room’s depth in focus and the whole room’s extension in pupil.

Beside a near object's edge the stack is blurrier than one focus, and more so the more exposures it hasThe far wall at 4 m seen beside the edge of a table at 0.5 m, its blur against the angular distance from the edge, for one focus (n = 1) and stacks of 2, 4 and 8. A wall point is usable from an exposure only where the table's blur disc in that exposure does not reach it, and the stack takes the sharpest usable one. One focus is seen through the table's blur for 2.7′ and then holds the wall to 5.27′. A stack has a usable exposure sooner, 1.9′ for 2, 1.4′ for 4, 1.0′ for 8, the one focused on the table, but that exposure blurs the wall badly, and the wall comes down to one focus's 5.27′ only at 4.2′, 6.6′, 8.6′, because the exposures that hold it sharply are shot wider open and blur the table further across it.010200102030distance on the wall from the table's edge (arcmin)blur of the wall (arcminutes)one focusstack of 2stack of 4stack of 8wall at 4 m behind a table at 0.5 mdotted: one focus's 5.27′
Fig. 3 The wall at 4 m beside the edge of a table at 0.5 m: the wall’s blur against the angular distance from the edge, for one focus and stacks of 2, 4 and 8, each point of wall taken from the sharpest exposure in which the table’s blur does not reach it.

Near the edge, every exposure sees the wall through some of the table’s blur, because a near object out of focus spreads its edge across whatever is behind it, the effect a pupil sees around an edge measured from the other side. A wall point is usable from an exposure only beyond the table’s blur radius in that exposure, and the merge can only choose among the usable ones. One focus at f/40 blurs the table by 5.27 arcminutes, so for 2.7 arcminutes beside the edge the wall is seen through the table, and beyond that it is held to 5.27.

A stack does worse beside the edge, and worse the more exposures it has. It has a usable exposure sooner, the one focused on the table, which barely blurs the table at all. But that exposure blurs the wall badly, by up to 20 arcminutes for a stack of eight, since its focus is half a metre away. The exposures that hold the wall sharply are focused far and, being shot wider open than one focus, blur the table further across the wall. So the wall beside the edge steps down through progressively farther-focused exposures, and comes down to one focus’s 5.27 arcminutes only at 4.2 arcminutes from the edge with two exposures, 6.6 with four and 8.6 with eight.

The band a stack spoils beside an edge widens with the count, as the far exposures open upThe width of the band of wall beside the table's edge that is either seen through the table's blur or blurrier than one focus's 5.27′ (solid, dots), against the number of exposures. One focus spoils 2.63′, the radius of its own blur of the table. A stack spoils 4.16′ with two exposures, 6.58′ with four and 11.29′ with twelve. Up to four it is exactly the table's blur radius in the farthest-focused exposure (dotted), whose pupil grows as the root of the count; beyond, an intermediate exposure clears the wall first, so the band grows more slowly than that and at five exposures narrows for a step.05102.5057.5010exposures in the stackband beside the edge (arcminutes)band spoiledfar exposure's table blurtable at 0.5 m, wall at 4 mtwelve: 11.29′
Fig. 4 The width of the band of wall beside the table’s edge that is seen through the table’s blur or blurrier than one focus, against the number of exposures, with the table’s blur radius in the farthest-focused exposure.

That band is the halo stacked pictures are known for, and its width is measurable. One focus spoils 2.63 arcminutes beside the edge, the radius of its own blur of the table. A stack spoils 4.16 with two exposures, 6.58 with four and 11.29 with twelve. Up to four exposures the band is exactly the table’s blur radius in the farthest-focused exposure, whose pupil grows as the square root of the count. Beyond, an intermediate exposure clears the wall a little earlier and the band grows more slowly, even narrowing for a step at five. In every case it is wider than one focus’s.

The trade has a simple shape. Each exposure’s pupil is 4.88λn/Δ\sqrt{4.88\lambda n/\Delta}, so its defocus of the table, seen from the far end of the room, grows as n\sqrt{n}, while its blur of the slice it was focused on falls as 1/n1/\sqrt{n}. What the stack gains in the middle of each surface it spends beside each edge, in the same currency, because both are set by how wide the far exposures are opened.

The first and last exposures see from different places

There is a second cost at the edge, and it is geometric rather than a matter of blur. The table’s edge comes from the exposure focused nearest, whose pupil is carried furthest forward by its focusing extension, and the wall comes from the one focused farthest, whose extension is least: 4.24 mm and 1.78 mm for two exposures, 5.22 mm and 0.91 mm for eight. So the two halves of the edge are seen from places between two and a half and four and a half millimetres apart along the axis.

A stacked edge is misregistered by the exposures' different pupils, nothing at the centre and most at the frame's edgeThe table's edge is kept from the exposure focused nearest and the wall behind it from the one focused farthest, and their pupils sit their focusing extensions apart, so the edge and the wall are seen from different places. Their relative position is off by tan θ times the extension difference times the depth between them: at the frame's edge, 19.8° off the axis, 5.32′ for two exposures, 7.99′ for four and 9.32′ for eight. It passes one focus's blur (dotted) at 19.6° for two exposures and 11.5° for eight, and the stack's own floor much sooner, 6.8° for four. One focus has one pupil and none of it.02.5057.501005101520field angle of the edge (degrees)misregistration at the edge (arcmin)stack of 2stack of 4stack of 8dotted: one focus's bluredge of frame, eight: 9.3′
Fig. 5 The misregistration of an occlusion edge, the table kept from the nearest-focused exposure and the wall from the farthest, against the edge’s field angle, for stacks of 2, 4 and 8, with one focus’s blur for comparison.

A forward step of the pupil moves every off-axis point outward by its field angle’s tangent times the step over its distance, and moves a near point more than a far one. The table’s edge and the wall beside it are therefore shifted against each other by tan⁡θ⋅(e1−en)⋅(1/znear−1/zfar)\tan\theta \cdot (e_1 - e_n)\cdot(1/z_{\text{near}} - 1/z_{\text{far}}). At the centre of the frame that is nothing. At the frame’s edge, 19.8° off the axis, it is 5.32 arcminutes for two exposures, 7.99 for four and 9.32 for eight, approaching the 10.7 the full extension difference would give. No alignment of the exposures removes it, because an alignment scales and shifts whole pictures and the two sides of the edge need different corrections. A stacker that aligns on the wall leaves the table’s edge displaced; one that aligns on the table leaves the wall displaced; either way the edge is drawn in the wrong place relative to what is behind it.

One focus has one pupil and none of this. It is the refocused panorama’s seam of a refocused panorama is six lenses, moved from between frames to inside one frame: there, two frames focused differently disagreed along the line where they were stitched; here, two exposures focused differently disagree along every occlusion edge in the picture. Focusing is a zoom found that each focus is a slightly different lens, and a stack is a picture assembled from several lenses along every edge where depth jumps.

Where in the frame a stack is right

Putting the two costs together gives a map of where a stack can be trusted.

The more exposures, the smaller the part of the frame where a stacked edge is registered as well as it is sharpFor each stack, the field angle out to which an occlusion edge's misregistration stays below one focus's blur of 5.27′ (solid) and below the stack's own blur (dashed). With two exposures the misregistration stays under one focus's blur out to 19.6° of the frame's 19.8°, and under the stack's own 3.73′ to 14.1°. With eight, to 11.5° and 4.1°. More exposures sharpen the stack and shrink the part of the frame in which its edges are where its sharpness says they are.0510152024681012exposures in the stackfield angle (degrees)edge of the framebelow one focus's blurbelow the stack's ownan occlusion edge, table against walleight: within 11.5°
Fig. 6 For stacks of 2 to 12 exposures, the field angle out to which an occlusion edge’s misregistration stays below one focus’s blur, and below the stack’s own blur.

With two exposures, the misregistration at an occlusion edge stays below one focus’s 5.27 arcminutes almost to the frame’s edge, out to 19.6° of its 19.8°, and below the stack’s own 3.73 out to 14.1°. With eight, it stays below one focus’s blur only out to 11.5° and below the stack’s own 1.86 only to 4.1°. The more exposures, the sharper the stack and the smaller the part of the frame in which its edges are where its sharpness says they are. Outside that part, a twelve-exposure stack shows a wall rendered to a minute and a half of arc with a table’s edge misplaced against it by nine.

So the answer to the essay’s question is a count that depends on what the frame holds. For a frame of continuous surfaces, a landscape seen across a field, a document lying at a slant, every additional exposure pays, and the seams never catch up. For a frame with occlusion edges near its own edge, two exposures already misregister those edges by about as much as one focus blurs them, and more exposures make the misregistration larger while making everything else sharper. One focus stopped down is never as sharp as a stack in the middle of a surface, and never wrong at an edge.

How large these are in pixels

The earlier essays measured in arcminutes and took sixty pixels to a degree, so that an arcminute was a pixel. A fifty-millimetre lens on a full-frame sensor six thousand pixels across spreads them over 39.6°, about 150 to the degree, so an arcminute there is two and a half pixels. On that sensor one focus at f/40 blurs every point of the room over about thirteen pixels. A stack of eight holds every continuous surface to under five pixels, which is the difference between a picture that looks soft when viewed at full size and one that does not.

Beside the table’s edge the same stack spoils a band of wall about twenty-one pixels wide, and at the frame’s edge it draws the table’s outline twenty-three pixels away from where it belongs against the wall, while one focus draws it in place inside its thirteen-pixel blur. A viewer looking at the whole picture on a screen sees the sharpness and not the edges. A viewer looking at full size at the frame’s corner sees an outline that the wall behind it does not agree with, which in a stacked picture looks like a seam with nothing on either side of it to explain it. Both are the same stack, judged at two magnifications, which is the sharp band is a decision’s point about blur, carried over to registration.

What this means for a photographer

Stacking is used most in close-up photography, where the reciprocal depth of a small subject is large and one focus can hold it only at apertures where diffraction is severe. The same arithmetic applies there with larger numbers. A subject a few centimetres away has a reciprocal span of tens per metre, the extensions are millimetres per slice, and the occlusion edges are the subject’s own outline against its background. The halos stacking software is known to leave around such outlines are the band measured here, and their width follows from the farthest exposure’s pupil, not from the software.

Two rules follow. Stack a subject seen against a background close behind it, so that the jump in depth at its outline is small, since both costs scale with that jump. And put the outlines that matter near the middle of the frame, since the misregistration grows with the tangent of the field angle and vanishes on the axis. A focusing rail, which moves the whole camera instead of turning the focus, moves the pupil by the change of subject distance itself, far more than a focusing extension, and is not measured here.

The room and the stack, as assumed

Equal slices of reciprocal distance and each exposure at its slice’s best pupil. A stacker that shoots every exposure at one aperture reaches a different floor, and one that spaces its focuses unequally can trade blur between slices. The equal split is the one the closed form assumes and the measurement confirms.

Blur and diffraction combined by root sum of squares, as in the earlier essay, and stated there as the assumption the floor is most sensitive to.

A merge that chooses whole exposures point by point. Real stacking software weights and blends neighbouring exposures, which softens the steps in the wall’s blur beside an edge but cannot make usable a point that every exposure sees through the table’s blur.

The pupil carried forward by the focusing extension, as the thin-lens model of the earlier essays has it. A lens that focuses by moving an internal group shifts its pupil differently, usually by less, and the misregistration scales with whatever shift it has.

Still open: whether a stack can be shot from one pupil

The misregistration at an edge exists because each exposure’s pupil is in a different place. A camera on a rail that moves backward by each exposure’s extension as the lens focuses forward, the tracking head of the panorama essays turned into a stacking rig, would put every exposure’s pupil in the same place. The halo would remain, since it is a matter of how wide the far exposures are opened and not of where they stand, but the edge’s two sides would then be seen from one point.

The measurement that settles what such a rig buys moves the camera back by each exposure’s extension, and asks how far the occlusion edge’s misregistration falls once the pupils coincide, leaving only the walk of the pupil with field angle that no rig removes, which the entrance pupil walks with the angle measured; whether the magnification each focus brings, which a stacker currently 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 band beside an edge can be narrowed by choosing the far exposures’ apertures by their effect on the edge rather than on their own slice, so that a stack trades its interior sharpness for its edges deliberately rather than by default.

A stack shot from one pupil is one picture scaled takes that measurement: with every pupil at one place each exposure is the same projection scaled, so the misregistration goes entirely and breathing becomes one known scale per exposure; the rail must hold its pupils to about 0.7 mm, and stopping the far exposures down trades the halo deliberately, twelve at half their pupils beating four at full on both counts.

A focus stack holds a continuous surface to 2.44λΔ/n\sqrt{2.44\lambda\Delta/n}, sharper than one focus with two exposures and sharper again with every exposure added, and its seams between neighbouring exposures stay a quarter of that. Where a near object stands in front of a far one, the stack meets its first exposure and its last. The far exposures are shot wider open, so they blur the near edge across more of what is behind it, a band from 2.6′ at one focus to 11.3′ at twelve exposures, and the two sides of the edge come from pupils a focusing extension apart, misregistered by up to 9.8′ at the frame’s edge. One focus has one pupil and neither cost.

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