As magnification increases, depth of field disappears. There is no magic solution. You either accept blur, reduce throughput, or use computational techniques.


The problem
High magnification creates an extremely small depth of field, while real parts have:
- Part warpage
- Height variation
- Focus drift over time
The problem, with numbers
A concrete case: an NA 0.28 objective gives roughly 7 um of depth of field. The parts arrive with up to 150 um of warpage across the field of view.
slices needed = warpage / usable DOF
= 150 um / 5 um (DOF with margin)
= 30 slices
per slice: 5 ms exposure + 20 ms move-and-settle = 25 ms
per stack: 30 x 25 ms = 750 ms per field of view
Three-quarters of a second per field of view, before any processing. If the part needs 40 fields, that is 30 seconds of pure acquisition. This single calculation decides whether focus stacking is viable for the application - do it before building anything.
The two levers that matter most: move-and-settle time (a fast, well-damped Z axis is worth more than a faster camera) and smart slice placement (if a height map tells you where the surface is, you can often cut 30 blind slices down to 8 targeted ones).
Approaches tried
- Closing the aperture (loses light and resolution).
- Increasing illumination (helps, but only so far).
- Accepting blur (sometimes acceptable, often not).
- Focus stacking - capture multiple images at different focus positions and combine the sharp regions into a single image.
What goes wrong in practice
- Vibration between slices shifts the images slightly, producing ghost edges in the composite. Registration helps; stiff mechanics help more.
- Reflective surfaces fool sharpness metrics - a blurred bright reflection can score "sharper" than fine dark texture. Choose the focus metric per material, not per textbook.
- Halo artifacts at sharp height steps, where the algorithm blends in-focus foreground with out-of-focus background. Visible as a glow around tall features; mostly cosmetic, occasionally a false call.
- Focus drift over hours quietly shifts the stack window until the surface falls out of it. Track where in the stack the sharp slices land - if the maximum migrates toward an end of the range, the system is telling you it is drifting.
Lessons learned
Focus stacking is never purely an imaging problem. Success depends on:
- Stable mechanics
- Precise, repeatable motion
- Good software
- Enough processing power and storage throughput
Most discussions focus only on optics. That is usually a mistake.