Answers / Technique
How many photos do you need for focus stacking?
Desk-researched answer
Short answer
For a scene that runs from a near detail to the horizon, take the hyperfocal distance divided by twice the distance to your nearest detail, rounded up. Focus the frames at the hyperfocal distance H, then H/3, H/5, H/7 and so on until the nearest frame reaches the nearest detail. With a 24 mm lens at f/8 on full frame and a foreground 0.5 m away, that is 3 frames for a picture seen whole, 7 for a 24-megapixel file inspected at 100% and 9 for a 45-megapixel file at 100%. The standard of sharpness you choose changes the count more than anything else, so choose it first. Space the frames evenly in 1 ÷ distance, not in metres: most of them belong in the first metre or two. For a close-up, divide the subject's depth by the depth one frame covers.
Cambridge in Colour suggests starting with "just 2-3 images" when a single frame almost had enough depth (its focus-stacking tutorial), and Nikon says an insect can take "over a hundred shots" (Nikon USA). Both can be right. When Afterlight put the 24 mm, f/8, 0.5 m scene above to five AI assistants on 21 October 2026, naming the 45-megapixel camera in the question, the answers still ran from 3 to 20 frames. The ones that showed their working all used the same geometry. They differed in how much blur they allowed, and only some of them said so.
Why focus steps grow with distance
A point that sits off the focus distance blurs in proportion to the difference between 1 ÷ its distance and 1 ÷ the focus distance, not to the difference in metres. So every frame at a given aperture covers the same span on a scale of 1 ÷ distance, and the frames march out in steps that look tiny up close and enormous far away.
The thin-lens depth-of-field equations (Greenleaf's, as given by DOFMaster) put the near and far limits of a frame focused at s at about 1 ÷ (1/s + 1/H) and 1 ÷ (1/s − 1/H), where H is the hyperfocal distance. Each frame therefore covers a span of about 2/H in 1 ÷ distance, wherever it is focused; the exact equations make it slightly narrower close up. ZEISS's depth-of-field paper gives the familiar consequences: focused at H, a frame is sharp from H/2 to infinity (page 12), and focused at H/3, it holds twice as much depth behind the focus as in front (page 15), which works out to H/4 to H/2. Carry on and a stack that leaves no gaps focuses at H, H/3, H/5, H/7 and so on, each frame picking up where the previous one stopped.

Original Afterlight diagram from the focus-stack-frame-count calculation, for an ideal 24 mm lens on full frame with a blur limit of 0.0088 mm; not a photograph. Bars are each frame's zone of acceptable sharpness; the dark marks are where each frame is focused.
Spacing the frames evenly in metres, as Cambridge in Colour's "evenly spaced focusing distances" reads, does the opposite of what the scene needs. Put the same nine frames at equal steps between 0.5 m and 8.2 m and everything from 0.53 m to 1.24 m falls between frames, with the worst point, at 0.74 m, blurred to five and a half times the standard. That is the foreground the stack was for.
Landscape photographers who bracket by calculation already work this way: the Grayheron landscape bracketing script for CHDK, the unofficial add-on firmware for Canon compacts, sets each focus step so that one frame's far limit meets the next frame's near limit, with an optional overlap as insurance.
Choose the sharpness standard before you count
The blur limit is the size of blur spot you are prepared to accept at the boundary between two frames. Choose it from how closely the picture will be looked at, the same way the motion-blur guide chooses a shutter speed.
| How the picture will be seen | Blur limit, full frame | Hyperfocal distance, 24 mm at f/8 |
|---|---|---|
| Whole, on a screen or a print at normal viewing distance | 0.030 mm, about 1/1500 of the diagonal | 2.4 m |
| A 24 MP file at 100%, or a large print viewed close | 0.012 mm, 2 pixels on 24 MP | 6.0 m |
| A 45 MP file at 100% | 0.0088 mm, 2 pixels on 45 MP | 8.2 m |
The first row is the standard behind depth-of-field scales and calculators; ZEISS explains it on page 19 of its paper. It is fine for a picture seen whole and too loose for anyone who zooms in, which is most people who bother to focus stack.
The strictest row has a hard floor, and it sits close to f/8. Diffraction blurs every point a little, however carefully the frames are spaced. Zerene Systems, which makes the stacking software of the same name, notes that a blur limit of about 0.0011 × the effective f-number, in millimetres, matches the size of the diffraction blur (Zerene's depth-of-field calculator notes). At f/8 that is 0.0088 mm, which is also 2 pixels on a 45-megapixel full-frame sensor. Asking for a tighter limit at f/8 adds frames without adding detail. At f/11 the floor is 0.012 mm, so a 45-megapixel camera at f/11 can only meet the 24-megapixel standard. A 61-megapixel camera needs about f/6.3 or wider to use its pixels; at f/5.6 a stack takes about 40% more frames than at f/8 for the same blur limit.
How many frames to infinity, by lens and nearest distance
Divide the hyperfocal distance by twice the distance to the nearest detail that has to be sharp, and round up. The hyperfocal distance is about focal length² ÷ (f-number × blur limit), so the count is:
frames ≈ focal length² ÷ (2 × f-number × blur limit × nearest distance), all in millimetres.
Close up, frames hold a little less depth than that simple form assumes, so multiply the result by 1 + focal length ÷ (2 × nearest distance) before rounding up. The correction is 2% for a 24 mm lens at 0.5 m and 8% for a 50 mm lens at 0.3 m, but it decides the count whenever the simple form lands just under a whole number.
With a 24 mm lens at f/8, the 45-megapixel blur limit of 0.0088 mm and a foreground 500 mm away: 576 ÷ (2 × 8 × 0.0088 × 500) = 8.2, times 1.024 is 8.4, so 9 frames. With the 24-megapixel limit of 0.012 mm the same sum gives 6.0, and the close-range correction takes it to 6.1, so 7 frames. If the far end is a wall or a treeline rather than the horizon, use (H ÷ 2) × (1/nearest − 1/farthest) instead.
| Focal length | Nearest detail 0.3 m | 0.5 m | 1 m | 2 m |
|---|---|---|---|---|
| 16 mm | 2 / 5 / 7 | 2 / 3 / 4 | 1 / 2 / 2 | 1 / 1 / 1 |
| 24 mm | 5 / 11 / 15 | 3 / 7 / 9 | 2 / 4 / 5 | 1 / 2 / 3 |
| 35 mm | 10 / 23 / 31 | 6 / 14 / 19 | 3 / 7 / 9 | 2 / 4 / 5 |
| 50 mm | — | 11 / 28 / 38 | 6 / 14 / 19 | 3 / 7 / 9 |
Frames needed at f/8 on full frame to hold everything from the nearest detail to infinity, for a picture seen whole / a 24 MP file at 100% / a 45 MP file at 100%. Calculated for an ideal lens, not measured; distances are from the lens. Most 50 mm lenses don't focus at 0.3 m.
Two things stand out. The count rises with the square of the focal length, so a 50 mm stack from 0.5 m takes about four times as many frames as a 24 mm one. It falls in direct proportion to the nearest distance: step back from 0.5 m to 1 m, or leave out the closest stone, and you halve it.
On APS-C, use the same formula with the blur limit for a picture seen whole scaled down by the crop factor (0.02 mm instead of 0.03 mm). For pixel-level viewing, use 2 pixels or 0.0011 × the f-number, whichever is larger: the diffraction floor doesn't shrink with the sensor, so at f/8 any APS-C body above about 20 megapixels should use 0.0088 mm. A smaller limit only adds frames.
Placing the frames when you focus by hand
The focus distances for the 24 mm, f/8 scene with a foreground at 0.5 m, from the near frame out, are:
| Standard | Focus distances |
|---|---|
| Seen whole (3 frames) | 0.49, 0.81, 2.4 m |
| 24 MP at 100% (7 frames) | 0.47, 0.56, 0.68, 0.87, 1.2, 2.0, 6.0 m |
| 45 MP at 100% (9 frames) | 0.49, 0.56, 0.64, 0.76, 0.92, 1.2, 1.7, 2.7, 8.2 m |
Calculated for an ideal lens; distances are measured from the lens.
Few lenses let you set 0.64 m, and you don't need to. Three habits get close enough:
- Fix the two ends first. Focus the near frame on the nearest detail and then a touch beyond it, checking in magnified live view that the detail is still sharp. Focus the far frame at the hyperfocal distance for your standard (the table above gives it for 24 mm; for other lenses, use focal length² ÷ (f-number × blur limit)).
- Turn the ring in equal steps between them. On a lens whose focus ring moves the optics mechanically, the lens moves out by about focal length² ÷ distance as it focuses closer. Equal turns of the ring are then equal steps in 1 ÷ distance, which is what the stack needs. Count the frames, and divide the turn between the two ends into that many equal steps. Internal-focus designs and focus-by-wire lenses only approximate this, so check the boundaries.
- Measure the nearest distance from the front of the lens. Camera distance readouts and the focal-plane mark measure from the sensor, which makes the nearest detail seem farther than it is and the count too low. At 0.3 m with a wide-angle lens, that error is worth a fifth of the frames or more.
Then magnify playback on a detail halfway between two focus positions. If it is soft at your viewing standard, add a frame there.
Each extra frame does the work of a larger f-number
A stack of n frames at f/8 holds the same depth as one frame at f/(8 × n), and it keeps the diffraction of f/8. That is the whole case for stacking: to hold 0.5 m to infinity in one frame with a 24 mm lens, you would need f/20 for a picture seen whole and f/67 for a 45-megapixel file at 100%. No lens offers f/67, and diffraction there would blur every point many times more than the standard allows. Nine frames at f/8 do the same job.
The same arithmetic tells you when a stack isn't needed, because one frame focused at H holds H/2 to infinity:
| Focal length | f/8, seen whole | f/8, 45 MP at 100% | f/11, seen whole | f/11, 100% |
|---|---|---|---|---|
| 16 mm | 0.54 m | 1.8 m | 0.40 m | 0.98 m |
| 24 mm | 1.2 m | 4.1 m | 0.89 m | 2.2 m |
| 35 mm | 2.6 m | 8.7 m | 1.9 m | 4.7 m |
| 50 mm | 5.2 m | 17.8 m | 3.8 m | 9.5 m |
The nearest detail one frame can hold with the horizon sharp, on full frame; double a figure for that column's hyperfocal distance H. The f/11 100% column uses 0.012 mm, the diffraction floor at f/11, for both 24 MP and 45 MP cameras.
If your nearest detail is farther than the figure for your lens and standard, one frame does it. With a 24 mm lens at f/11 and nothing closer than about 0.9 m, a single frame is enough for a picture seen whole. The f/16 guide weighs what stopping down further costs; stacking is the way around that cost for a scene that holds still.
The choice of f-number for the stack itself is a trade between frames and fine detail. Canon's focus bracketing instructions recommend f/5.6 to f/11, and Nikon's Z8 manual recommends "apertures wider (f-numbers lower) than f/8–f/11". Cambridge in Colour suggests f/11 to f/16 "with SLR cameras"; at f/16 the diffraction floor is about 0.018 mm, coarser than the 24-megapixel standard. On full frame, f/8 is the sensible default: it sits at the narrow edge of both makers' advice and keeps frame counts manageable. Open to f/5.6 only on a camera of 60 megapixels or more, or when your lens is clearly sharper there.
Setting focus bracketing on the camera
In-camera focus bracketing sets the step for you, but none of the major makers says how big a step is in depth-of-field terms. The steps are relative and already scaled to the aperture:
- Canon: the focus increment "is automatically adjusted to suit the aperture value", and a larger f-number covers a wider range at the same setting (EOS R6 Mark III manual). One tester, Jason Franke of Points in Focus, found that on his EOS R5 an increment of 8 moved focus about one conventional depth of field (his notes). That is one measurement on one body; if it holds for your camera, an increment of about 3 suits the 24-megapixel standard and 2 the 45-megapixel one.
- Nikon: the step "is calculated by the camera based on a variety of lens data, including focal length and aperture", and Nikon recommends a step width of 5 or less, or 2 to 3 for large prints (Nikon USA's focus-shift guide). The Z8 manual adds "smaller focus steps" and more shots "when photographing subjects close to the camera", and the D850 guide recommends "taking more shots than you think you'll need".
- Sony: the step width "is a relative value, and the focus interval varies depending on shooting conditions such as the aperture of the lens and the initial focus position"; Sony recommends a test shot (α1 help guide).
- Fujifilm: in AUTO mode you focus on the nearest and farthest ends of the subject and the camera calculates the number of frames and the step (X-T5 manual). The manual doesn't say what standard of sharpness it uses. In MANUAL mode you set the step and frames yourself, and shooting "ends when focus reaches infinity".
Canon, Nikon, Sony and Fujifilm's MANUAL mode all stop when focus reaches infinity, so the safe way to shoot a landscape is to focus on the nearest detail, set the number of shots well above what you expect, and let the camera end the run. Then count. If the camera reached infinity in fewer frames than the table gives for your lens, distance and standard, its steps were too wide for that standard. Choose a smaller step and shoot again. It is a cheaper check than finding a soft band in the merged file at home.
Close-ups: divide the subject's depth by one frame's depth
At close range the distances across a subject barely change, so equal steps in 1 ÷ distance become equal steps in millimetres. The frame count is the subject's depth divided by the depth one frame covers, rounded up. For magnification m, one frame covers about 2 × f-number × blur limit × (1 + m) ÷ m² in millimetres, or the diffraction limit Zerene gives, 0.0022 × f-number² × (1 + m)² ÷ m², whichever is larger. Zerene's macro depth-of-field tables list the second figure by magnification and aperture.
| Magnification | f/5.6 | f/8 | f/11 |
|---|---|---|---|
| 1:4 (0.25×) | 2 / 6 | 2 / 3 | 1 / 2 |
| 1:2 (0.5×) | 5 / 17 | 4 / 8 | 3 / 5 |
| 1:1 | 15 / 37 | 11 / 18 | 8 / 10 |
Frames for a subject 10 mm deep, on full frame: seen whole / pixel level on 45 MP, or as sharp as diffraction allows at that aperture where diffraction is the larger blur. Scale linearly for other depths. Calculated for an ideal lens; not measured.
Magnification also raises the effective f-number. At 1:1, f/8 behaves like f/16 at the sensor. In eight of the nine cells above, diffraction sets the second figure, and the 45-megapixel standard can't be reached. Fewer frames at a smaller aperture therefore buy a softer result, not the same one: at 1:1 the 10 frames at f/11 carry about twice the blur of the 37 at f/5.6. Zerene's formula assumes a symmetrical lens; its calculator takes a pupil ratio for the rest. A flower head 30 mm deep at 1:2 and f/8 takes about 24 frames inspected at 100%; an insect 15 mm deep at 1:1 and f/5.6 takes about 55. That squares with Nikon's D850 focus-shift guide, whose tables for its 60 mm and 105 mm macro lenses list 15 to 300 shots for subjects 1 to 15 inches in size. Some recent Nikon macro lenses already display the effective f-number; Zerene's page explains which table to use for those.
Add a frame or two for what the arithmetic leaves out
The counts above let neighbouring frames just touch, with the blur at each boundary exactly at the limit. A few things in the field make that tighter than it looks:
- Focusing by hand is imprecise. Lens distance scales are coarse, and the near frames sit centimetres apart. Add a frame, or shoot the near end in smaller steps than it strictly needs. Zerene suggests that many photographers use about 0.7 of the calculated step in macro work.
- Real lenses don't focus on a flat plane. Field curvature can leave the corners of a boundary zone softer than the centre. The group-photo Answer cites Lensrentals' measurements of how far the focus surface of fast 35 mm lenses curves.
- Focusing changes the framing slightly. Most stacking software aligns the frames and crops the edges, so leave room around the composition.
- Wind and light don't wait. A grass foreground that moves between frames can't be stacked cleanly, whatever the count. A shorter stack at f/11 can beat a long one at f/8 in a breeze. If something in the frame moves during each exposure as well, the motion-blur guide gives the shutter speed it needs.
Check the result at the size the picture will be seen. In Nikon USA's example, a stack shot with the widest step showed alternating strips of sharp and soft detail, "largely invisible except when the image is zoomed in at an extreme zoom of 400% - 800%". Steps too wide for one standard can be fine for a looser one.
How this answer was made: AI-assisted research, calculation and writing. The frame counts come from the thin-lens depth-of-field equations as given by DOFMaster, with the far frame at the hyperfocal distance and each nearer frame's far limit meeting the next frame's near limit; distances are measured from an ideal lens. Macro counts use the classic close-up depth-of-field formula and Zerene's diffraction estimate, taking the larger. Lens aberrations, field curvature and focus error are not modelled. The camera behaviour comes from the linked manuals and makers' guides; Afterlight did not shoot a stack for this answer. The AI answers came from GPT-6 Luna, GPT-5.6 Sol, Gemini 3.8 Flash, Claude Sonnet 5.5 and Perplexity Sonar Pro on 21 October 2026. The calculation is in Afterlight's test library as focus-stack-frame-count.