Macro Focus Stacking Calculator

Enter the magnification, aperture, camera resolution, subject depth, and overlap target to estimate the rail step and minimum number of frames for a macro stack.

Your numbers
Enter 1 for life-size reproduction, 2 for 2:1, or 0.5 for 1:2.
Use the f-number selected on the lens or camera.
Enter exit-pupil diameter divided by entrance-pupil diameter, or leave 1 for a symmetric-lens estimate.
Use the physical width of the camera sensor.
Enter the uncropped horizontal pixel dimension of the photograph.
This converts sensor resolution into the acceptable circle of confusion used for stacking.
Measure the front-to-back subject depth that must appear sharp.
Extra overlap between adjacent depth-of-field zones provides a margin for optical and positioning error.

What this calculator leaves out

  • This estimate uses a close-up optical model and cannot account for every lens design, subject shape, rail, or stacking-software behavior.
  • The diffraction warning is informational and is not a guarantee of visible image quality for a specific camera, lens, processing workflow, or viewing size.

By using this calculator you agree to the Terms of Use. Results are estimates, not professional advice.

Recommended rail step (mm)0.19

Macro depth of field (mm)
0.27
Minimum number of frames
53
Effective aperture
f/11.2
Diffraction Airy diameter (pixels)
2.51
Diffraction assessment
Diffraction exceeds the selected blur tolerance

Depth of field is object-side and uses the circle of confusion implied by sensor width, image width, and blur tolerance.

Diffraction is estimated with 550 nm green light at the effective aperture.

How to use this calculator

  1. Enter the subject magnification shown by your lens setup or measured from the image scale.
  2. Enter the marked aperture and pupil magnification, or leave pupil magnification at 1 for a symmetric-lens estimate.
  3. Enter the sensor width, image width, and blur tolerance so the circle of confusion follows your camera resolution.
  4. Measure the front-to-back subject depth that must appear sharp and choose the overlap between focus slices.
  5. Use the rail step and frame count as a starting plan, then add boundary frames when the setup is hard to repeat.

How the stack spacing is calculated

At macro distances, depth of field is driven mainly by magnification, aperture, and the circle of confusion you are willing to accept on the sensor. This calculator starts with the camera resolution instead of a generic print-based circle of confusion. Pixel pitch is p = W / X, where W is sensor width in millimeters and X is image width in pixels. The acceptable blur circle is c = b * p, where b is the blur tolerance in pixels.

The effective aperture used for close-up work is Ne = N * (1 + m / P). N is the marked f-number, m is subject magnification, and P is pupil magnification, defined as exit-pupil diameter divided by entrance-pupil diameter. If you do not know the pupil magnification, 1 is a reasonable symmetric-lens estimate, but some internal-focus macro lenses and reversed lenses can differ enough to matter.

The object-side macro depth of field is:

T = 2 * c * Ne / m^2

The recommended rail step is the depth of field reduced by the requested overlap:

s = T * (1 - O / 100)

If the subject depth D is no more than one depth-of-field interval, the result is one frame. Otherwise the frame count is F = ceil((D - T) / s) + 1. This assumes the first and last focus planes sit about half an interval inside the front and rear subject boundaries.

What changes the result most

Magnification is the strongest lever because it is squared in the denominator. Moving from 1:1 to 2:1 can quarter the depth of field before aperture changes. A smaller marked aperture increases depth of field and the rail step, but it also raises the effective aperture and can make diffraction blur larger than the blur tolerance you selected. More overlap gives safer coverage, at the cost of a smaller step and more frames.

What this calculator leaves out

The model is a paraxial close-up estimate. It assumes magnification stays effectively constant as the rail moves and that the subject has a flat enough depth requirement to be represented by one front-to-back number. Real stacks can need tighter spacing because of field curvature, focus breathing, aberrations, rail backlash, vibration, subject motion, lighting drift, and stacking-software alignment limits. The diffraction estimate uses the Airy-disk diameter a = 2.44 * 0.00055 * Ne / p in pixels for green light; adding more frames cannot recover detail softened by diffraction.

Worked example

Suppose a full-frame camera has a 36 mm sensor width and records 6000 pixels across. At 1:1 magnification, f/5.6, pupil magnification 1, a 2-pixel blur tolerance, a 10 mm subject depth, and 30% overlap, the pixel pitch is 36 / 6000 = 0.006 mm and the circle of confusion is 2 * 0.006 = 0.012 mm.

The effective aperture is 5.6 * (1 + 1 / 1) = f/11.2. The macro depth of field is 2 * 0.012 * 11.2 / 1^2 = 0.2688 mm, so the 30% overlap rail step is 0.2688 * 0.70 = 0.18816 mm. Covering 10 mm takes ceil((10 - 0.2688) / 0.18816) + 1 = 53 frames. The Airy diameter is about 2.51 pixels, so the calculator warns that diffraction exceeds the selected 2-pixel blur tolerance.

Common questions

What focus-stack overlap percentage should I use?

A 20% to 40% overlap is a practical starting range for controlled macro work. Use more overlap when magnification is high, the rail is imprecise, the subject has fine texture, or missed focus bands would be hard to repair.

How do I measure macro magnification?

Photograph a ruler at the same setup and divide the image size on the sensor by the real subject size. On a 36 mm wide sensor, if the frame covers 18 mm of ruler width, the magnification is 36 divided by 18, or 2:1.

What is pupil magnification and when does it matter?

Pupil magnification is exit-pupil diameter divided by entrance-pupil diameter. It affects effective aperture and close-up depth of field, especially with asymmetric lenses, internal-focus macro lenses, microscope objectives, and reversed lenses. If you do not have lens data, 1 gives a symmetric-lens estimate.

Should I move a focus rail or change lens focus?

For high magnification, a rail usually keeps magnification more consistent and makes step size easier to control. Changing lens focus can work for modest close-ups, but focus breathing may alter framing and complicate alignment.

Can focus stacking overcome diffraction?

No. Focus stacking combines sharp slices from different distances, but each slice still carries the diffraction blur created by the selected effective aperture. If the Airy diameter is larger than your blur tolerance, opening the aperture and taking more frames may preserve more detail.

How many frames are needed for a 1:1 macro stack?

It depends on aperture, sensor resolution, blur tolerance, subject depth, and overlap. With the default full-frame 6000-pixel setup at 1:1 and f/5.6, a 10 mm subject depth with 30% overlap needs 53 frames.

Put this calculator on your site

Paste the snippet below where you want the calculator to appear. It stays up to date automatically and links back here.

<iframe src="https://countfolk.com/embed/macro-focus-stacking-calculator/" title="Macro Focus Stacking Calculator" width="100%" height="640" style="border:0;max-width:44rem" loading="lazy"></iframe>