Calculator

Depth of field and focus-stacking calculator

Near and far limits, hyperfocal distance, and the number other calculators skip: the focus step and frame count a stack needs at your aperture.

Calculator

Depth of field, hyperfocal distance and the stacking step

Enter the lens, the aperture and either the focus distance or the magnification. The result is the sharp zone for one frame, and the step and frame count a stack needs to cover your subject.

How do you know the framing?

Distance mode uses the focal length and focus distance; magnification mode uses the reproduction ratio and already accounts for effective aperture.

Sets the circle of confusion: 0.030 mm full frame, 0.019–0.020 mm APS-C, 0.015 mm Micro Four Thirds.

mm

Actual focal length, not the full-frame equivalent.

f/

The f-number set on the lens. At high magnification the effective aperture is larger; the macro mode accounts for it.

cm

From the sensor plane to the point of focus. Used in distance mode.

×

1 = life size (1:1), 0.5 = half life size (1:2). Used in macro mode.

mm

Front to back of what must be sharp. 12 mm is a large beetle; 3 000 mm a foreground rock to a fence.

%

How much each frame's sharp zone overlaps the next. 30 % is the usual floor; 50 % is safer for a difficult subject.

The arithmetic, stated

lens, left one frame's depth of field, three frames subjectstep ≤ DoF × 0.7

Each frame is sharp in one slice as deep as the depth of field; step the focus by less than a slice and the slices overlap.

Hyperfocal distance H = f² ⁄ (N·c) + f, where f is the focal length, N the f-number and c the circle of confusion for the sensor. For a focus distance s, the near limit is s(H − f) ⁄ (H + s − 2f) and the far limit s(H − f) ⁄ (H − s), infinite once s reaches H. In macro mode, where you know the magnification m rather than the distance, the depth of field is 2·N·c·(1 + m) ⁄ m², which already contains the effective-aperture growth.

The stacking step is one frame's depth of field times (1 − overlap), and the frame count is the subject depth divided by the step, plus one, so the first and last frames sit beyond the subject. Most depth-of-field calculators stop at the first paragraph; the second is why this one exists.

Which circle of confusion?

The values here are the conventional ones for a print viewed at normal distance. If you inspect at 100 % on a 45-megapixel sensor, halve them — and expect the frame count to double. The calculator is a planning tool; the stacker's inspector is the judge.

Worked examples: how many frames a 12 mm subject needs

Every row is computed by the same code as the calculator above, for a full-frame sensor (circle of confusion 0.030 mm), a subject 12 mm deep — a large insect, a watch movement, a coin on its edge — and 30 % overlap between neighbouring slices. Magnification is the reproduction ratio: 1× is life size, 0.5× half life size.

Frames for a 12 mm deep subject, full frame, 30 % overlap
MagnificationApertureDepth of field per frameFocus stepFrames
0.5×f/82.88 mm2.02 mm7
1×f/5.60.67 mm0.47 mm27
1×f/80.96 mm0.67 mm19
1×f/111.32 mm0.92 mm14
2×f/5.60.25 mm0.18 mm70
5×f/40.06 mm0.04 mm299

Magnification costs far more than aperture. Going from 1× to 2× at f/5.6 shrinks each frame's depth of field from 0.67 mm to 0.25 mm and the series from 27 to 70 frames, while stopping down from f/5.6 to f/11 at 1× only takes the count from 27 to 14. Stopping down is not free either: at life size the effective aperture is twice the marked one (f/8 behaves like f/16), and diffraction softens every frame on a high-resolution sensor. That is why macro stackers usually shoot around f/5.6–f/8 and accept more frames.

At ordinary distances the numbers relax. With the calculator's defaults — a 100 mm lens at f/8 focused at 50 cm on full frame — one frame holds about 9.60 mm of depth, so the same 12 mm subject needs 3 frames. Product and tabletop shots sit here; insects and minerals sit in the table.