Depth of Field

Depth of field collapses as 1/m², so a close-up job has almost none. Stopping down buys depth linearly — until diffraction takes over and the Airy disc grows past a pixel, at which point a smaller aperture only makes things blurrier. Those two effects bracket the usable aperture.

Total depth of field
Either side of focus
Airy disc diameter
DOF one stop down
Airy one stop down
Diffraction check

Circle of confusion is usually taken as one to two pixel pitches. This is the close-up (macro) form of the DOF equation, which is the right one for machine vision; classical photographic DOF formulas assume distant subjects.

A helper, not a substitute for engineering judgment. Verify against the governing standard.