
Focus stacking is shooting several frames of the same scene, each focused a little farther away, and merging them in software so the sharp part of every frame ends up in one picture. It is how you get a whole insect, a whole flower or a pebble at your feet and the mountains behind it sharp at once, when no single setting of the lens can do it.
It matters because depth of field runs out exactly where many photographers want it most. Close to the lens it shrinks to a millimeter or less, and the usual cure, a smaller aperture, softens the whole picture through diffraction long before it gives you enough depth. Stacking sidesteps that trade. Each frame is shot at the aperture where the lens is sharpest, and depth comes from the number of frames instead.
Why one frame cannot do it
A lens focuses on one distance, and depth of field is the zone around it where the blur is too small to notice. At landscape distances that zone is generous. Close up, where the subject is large in the frame (high magnification), it collapses. For a full frame camera, using the common 0.03 mm standard for “acceptably sharp” (the circle of confusion), total depth of field is roughly 2 × f-number × 0.03 × (magnification + 1) ÷ magnification squared. Worked through:
| Magnification | f/2.8 | f/5.6 | f/8 | f/11 | f/16 |
|---|---|---|---|---|---|
| 1:1 (life size) | 0.34 mm | 0.67 mm | 0.96 mm | 1.3 mm | 1.9 mm |
| 1:2 (half life size) | 1.0 mm | 2.0 mm | 2.9 mm | 4.0 mm | 5.8 mm |
| 1:4 | 3.4 mm | 6.7 mm | 9.6 mm | 13 mm | 19 mm |
| 1:10 | 18 mm | 37 mm | 53 mm | 73 mm | 106 mm |
Read the top row. A bee is about 12 mm from head to tail. At life size and f/8 you get under a millimeter of it sharp. Even f/16 gives you less than 2 mm. No aperture on any lens covers the whole bee in one frame. Plenty of fine macro photography is still single frames, often with flash at f/11 to f/16, with the photographer choosing which slice to keep sharp. Stacking is the answer when you want the whole subject sharp.
Why stopping down is not the answer
Two things work against a small aperture at close range. The first is diffraction: light spreading as it passes the edges of a small opening. The blur spot it makes grows with the f-number, about 11 microns across at f/8, 21 at f/16 and 30 at f/22 for green light. Pixels on a modern sensor are about 4 to 6 microns wide, so by f/16 each point of light is spread over several of them.
The second is that the f-number on the lens stops telling the truth when you focus close. At life size the light behaves as if the aperture were about two stops smaller than marked (the effective aperture is roughly the marked number × (1 + magnification), so f/8 acts like f/16). That is why a macro shot at a marked f/16 often looks soft all over: it was really diffracting like f/32. Stacking lets you stay around f/5.6 to f/8 marked, near the lens’s sweet spot, and get the depth you need anyway.
Want to see how thin the sharp zone gets as you focus closer or open up? Move the focus distance and aperture here and watch the near figures fall in and out of focus.
Is the depth of field idea itself still fuzzy? What depth of field is and the three things that control it starts from the beginning.
How the software builds one picture
Stacking software does three jobs. First it lines the frames up, because changing focus also changes the size of the image slightly (lenses “breathe”), and a tripod is never perfectly still. Then, for every small patch of the picture, it measures local contrast in each frame: a patch in focus has crisp edges and fine texture, the same patch out of focus is smooth. Finally it builds the output from the sharpest version of each patch, blending where neighboring frames are about equally sharp.
Most programs offer two ways to do the last step. A depth map method works out, for each spot, which frame was sharpest there and builds mostly from that frame, smoothing the joins. It tends to keep colors and tones true and handle smooth surfaces well, but can lose fine detail where many thin things cross each other. A pyramid method blends detail from all frames at several scales. It usually does better on fine, overlapping texture such as hairs and bristles, but can raise contrast, noise or color slightly. Programs differ in the details, so treat these as tendencies: when a stack goes wrong in one, it often works in the other, and careful workers combine both.
This also tells you what the software cannot do. It can only choose among the frames you gave it. If some slice of the subject was not sharp in any frame, the output is soft there, and no setting fixes it.
How far to move focus between frames
The one rule that matters: each frame’s sharp zone must overlap the next. If the step between frames is bigger than the depth of field, slices between them are sharp in no frame, and the result shows soft bands across the subject.
A safe step is about three quarters of one frame’s depth of field, which leaves a quarter overlapping. Then the frame count is the subject’s depth divided by the step, plus one. Two worked examples using the table above:
- A bee at life size, f/8. Depth of field 0.96 mm, step 0.72 mm, subject 12 mm deep: 12 ÷ 0.72 = 16.7, so 17 steps and 18 frames.
- A flower head 20 mm deep at half life size. At f/8 the depth is 2.9 mm, the step 2.2 mm, and you need 11 frames. At f/4 the same flower needs 20 frames. At f/16, only 6, but each one is softer from diffraction.
These counts use the 0.03 mm standard. If you plan to view the result large or crop hard, sharpness standards tighten, depth per frame shrinks, and you need more frames. In practice almost nobody measures; they shoot more frames than the arithmetic says. Spare frames cost a few seconds of processing. A missing frame costs the shot.
Landscapes: equal steps in one over distance
Far from the lens the picture changes completely. Depth of field grows fast with distance, so focus steps should start tiny and get much bigger. There is a neat way to see it: on a scale of one over distance (the way opticians count diopters), every frame at a given focal length and aperture covers the same width, except the last one focused at infinity, which covers the half that is left over.
Take a 24mm lens at f/8 on full frame. Its hyperfocal distance is about 2.4 m (24 × 24 ÷ (8 × 0.03) = 2,400 mm). Focused at 0.3 m it is sharp from about 0.27 to 0.34 m. Focused at 0.4 m, 0.34 to 0.48 m. At 0.6 m, 0.48 to 0.8 m. At 1.2 m, 0.8 to 2.4 m. Focused at infinity, 2.4 m to infinity. Five frames, each band touching the next, take a pebble 27 cm from the lens and the horizon and make them both sharp.
Two lessons come out of that. Most of the frames go to the first meter, so when you focus by hand, take small turns of the focus ring near the camera and big ones further out. And if your nearest subject is beyond about half the hyperfocal distance, you do not need a stack at all: one frame at the hyperfocal distance already covers it. Add a frame or two of overlap in real use, because the sharpness standard here is the lenient one.
Not sure whether your scene needs a stack or just good focus placement? Work out the hyperfocal distance for your lens and aperture and compare it with your nearest subject.
Shooting the stack, step by step
- Lock the camera down. Use a solid tripod and keep the center column down. Turn off image stabilization, which can nudge the image between frames when the camera is already still.
- Fire without touching the camera. Use a remote release, an app, or the 2 second self-timer. An electronic or electronic first curtain shutter removes the small jolt of the shutter itself, which matters most at high magnification; see mechanical vs electronic shutter for the catches.
- Fix the exposure. Use manual mode, a fixed ISO and a fixed white balance. If brightness or color shifts between frames, the merge shows patches.
- Pick the aperture. Around f/5.6 to f/8 marked for most lenses; at life size, f/5.6 already behaves like f/11.
- Switch to manual focus, magnify the live view, and find the nearest point you want sharp. Use focus peaking if your camera has it.
- Step through the depth. Take a frame, move focus a little further, take another, until the furthest point you want is sharp. Shoot one more frame past each end.
- Check before you leave. Scroll through the frames at full magnification. Every part of the subject should be crisp in at least one of them.
Focus ring, focusing rail or in-camera bracketing
There are three ways to move the plane of focus, and each has a place.
- Turning the focus ring needs no extra gear and works well for landscapes and short stacks. The catch is that every touch can move the camera, and at close range the image changes size as you focus, so the software has to rescale frames and you lose a little at the edges.
- A focusing rail leaves the lens alone and slides the whole camera toward the subject in small, even steps. Magnification stays nearly the same from frame to frame, which suits high magnification work where the steps are fractions of a millimeter. Motorized rails take the stack for you.
- In-camera focus bracketing (also called focus shift) drives the autofocus motor in steps you set, firing a frame at each one without you touching anything. You choose a starting point, a step size and a frame count. Step units are set by the camera maker and are not millimeters, so run a quick test and look for soft bands before a real shoot.
A lens with a long focus throw makes hand stepping easier, because a small turn moves focus only a little. If you notice your framing grow and shrink as you focus, that is focus breathing, and it is normal; the alignment step exists to undo it.
Macro, landscape and product stacks compared
The idea never changes, but the numbers and the main enemy do.
- Macro. Tens of frames, steps under a millimeter, and the enemy is movement. A breath of wind or an insect shifting a leg ruins the overlap. Work indoors or in still air at dawn, and if you light with flash, every frame is frozen and vibration matters far less. The insect and flower guides cover the field side; stacking is how both get a whole subject sharp.
- Landscape. Usually two to six frames, and the enemy is things that move between frames: grass, branches, water, clouds. Shoot the near frames first and quickly, and if the foreground keeps moving, take two or three passes so each distance has one still frame. Stacking pairs well with exposure blending when the scene is both deep and high in contrast, and with astro-landscapes, where the foreground and the stars are often focused and exposed separately.
- Product. Five to twenty frames on a still object under fixed lights, the easiest stack of all. The enemy is reflections and specular highlights changing shape as focus moves, which can confuse the blend. Commercial product photography uses stacking for jewelry, watches and anything small where every edge must be crisp.
Before you reach for a stack, check whether turning the camera would do. Depth of field is measured along the lens axis, so a flat subject square to the camera fits in one thin zone, while the same subject angled away needs many. A butterfly resting with its wings spread flat, shot from directly above or in front so the wings are square to the lens, is the classic case: tilt the camera until the wing is parallel to the sensor and one frame at a modest aperture holds it edge to edge.
Stacking earns its keep when something is very close to the lens, not just when the view is big. Try it in the simulator first: get the nearest rocks and the horizon both sharp without going past f/16. If you cannot, that is the gap a stack fills.
Merging and cleaning up
Process the frames the same way first. Shoot raw, make your exposure and color adjustments on one frame, copy them to all the others, and export full size files for the stacking program. Do not sharpen hard before stacking; the software judges sharpness, and artificial edges mislead it.
General editors stack by loading the frames as layers, aligning them and blending them automatically. That works for a handful of frames. Dedicated stacking programs handle dozens or hundreds of frames, offer both depth map and pyramid methods, and include a retouching brush that paints from one chosen source frame, which is how you repair the faults below. If you already work with layers and masks, you can do the same by hand: keep the stacked result on top and paint in a single source frame where it fails.
Crop a little at the end. Alignment shifts and rescales frames, which leaves a ragged or soft border.
Common mistakes with focus stacking
- Steps too big. Soft bands across the subject, like contour lines. The fix is more frames with smaller steps; it cannot be fixed afterwards.
- Not starting in front or finishing behind. The nearest antenna tip or the far horizon stays soft because no frame was focused there. Take one extra frame past each end.
- Stopping down to f/16 or f/22 “for safety”. You trade depth you no longer need for diffraction softness in every frame. At macro distances it is even worse than the marked number suggests.
- Halos around edges. A sharp near edge sits against a background that, in other frames, was a bigger blurred copy of the same edge. The software keeps a ghostly rim. Try the other blending method, or paint the area from a single frame.
- See-through foreground. Thin parts close to the lens, like hairs or grass stems, look transparent because frames focused behind them saw “around” them. Stack the frames where the foreground was sharp separately and paint that result over it.
- Movement between frames. Wind, a shifting insect or a changing cloud gives doubled edges. Calm air, faster stepping or flash prevents it; retouching from one frame repairs it.
- Auto exposure or auto white balance. Frame to frame shifts become blotches in the merge. Lock both.
- Thinking stacking fixes camera shake. Each frame still needs to be sharp on its own. If the frames are soft from shake, the stack is soft too.
Getting good enough at close range to need dozens of frames, but without a macro lens? Extension tubes, close-up filters and reversed lenses all stack the same way.
Try this: a ruler stack in ten minutes
You need a camera on a tripod and a ruler or tape measure. Lay the ruler flat on a table pointing straight away from the camera, and set the camera low, looking down at it at about 45 degrees, as close as your lens allows so the ruler fills the frame lengthwise.
- Set manual mode, f/5.6, a fixed ISO and manual focus. Use the self-timer.
- Focus on the nearest marks and take one frame. Zoom in on it and count how many millimeters of the ruler look crisp. Because you are looking down the ruler at an angle, that stretch is longer than the depth it spans along the lens axis: at 45 degrees the depth of field is about 0.7 times the crisp length.
- Now step focus back along the ruler, moving each time by about three quarters of that sharp stretch, until the far end is sharp. Count the frames as you go.
- Shoot a second stack with steps twice as big.
- Merge both stacks in any program that stacks.
Judge the results at 100 percent along the ruler. The first stack should be crisp from end to end. The second will likely show soft bands between sharp stretches, and the bands tell you exactly how big your steps can be. Multiply the crisp length from step 2 by 0.7 and compare it with the table above for your aperture and magnification; that is depth of field, measured by you.
Want to test what you have learned? The focus stacking quiz asks about steps, software and the faults above.
Focus stacking questions
How many frames do I need?
Divide the depth you want sharp by about three quarters of one frame’s depth of field, then add one. In practice that is 2 to 6 for a landscape with a close foreground, 5 to 20 for a small product, and 15 to 100 or more for an insect at life size, depending on the aperture and how deep the insect is (the bee above needs 18 at f/8).
Can I focus stack handheld?
Sometimes. At landscape distances, a fast burst while you turn the focus ring, or the camera’s focus bracketing, can be aligned in software. At macro distances some photographers rock slowly toward the subject while firing a burst, but expect more failures and more cleanup than from a tripod.
Is focus stacking the same as HDR or exposure bracketing?
No. Exposure bracketing varies brightness to cover a wide tonal range; focus stacking varies the focus distance to cover depth. Both merge several frames, and you can combine them, but they solve different problems.
Does aperture still matter if I am stacking?
Yes. Aperture sets how much depth each frame covers, so it sets how many frames you need, and it sets how sharp each frame is. A middle aperture is the usual balance: wide enough to avoid diffraction, small enough to keep the frame count reasonable.
Why does my stacked image look sharp but strange?
A stack can show more depth than the eye ever sees at that scale, with no soft areas to tell you which way is near. Many photographers stack only the subject and let the background stay soft, which keeps the picture readable and makes the subject stand out.
How does aperture change sharpness and depth in a single frame? Aperture and what it does to your photos covers it, with a comparison to try.