OptixwiseOptixwise

Tools / Depth of field

Depth-of-Field Calculator

Circle of confusion
From pixel pitch µm ×
Lens & focus
Acceptably sharp
Near limit—
Far limit—
Total depth—
Hyperfocal—
Magnification—

How to use, worked examples and FAQ

How to use this depth-of-field calculator

  1. Set the circle of confusion (CoC). This is the largest blur spot you still call sharp. Pick the full-frame or APS-C photography value, type your own in millimeters, or enter the sensor's pixel pitch and how many pixels of blur you accept and press Apply.
  2. Enter the lens and focus. Focal length in millimeters, the f-number, and the distance the lens is focused at.
  3. Read the result. The near and far limits bound the acceptably sharp zone. You also get total depth, hyperfocal distance and magnification, and the diagram shows how the zone sits around the focus point.

Working backwards? Switch to f/stop & focus, enter the nearest and farthest distances that must be sharp, and the calculator returns the f-number and focus distance that just cover them.

What sets depth of field

  • Focal length matters most. Hyperfocal distance grows with the square of focal length, which is why a 2.8 mm module lens is sharp from a few tens of centimeters to infinity while a 50 mm lens at the same f-number is not.
  • f-number. Depth of field grows roughly in proportion to N: one stop smaller roughly adds 40%.
  • Focus distance. Depth grows quickly with distance. Focused at or beyond the hyperfocal distance, everything from about half that distance to infinity is sharp.
  • Circle of confusion. Depth of field scales almost directly with CoC, so every depth-of-field figure is only meaningful together with the CoC behind it.

Worked examples

Fixed-focus security camera

A 2.8 mm f/2.0 lens on a sensor with 2.9 µm pixels, with a CoC of two pixels (5.8 µm). Hyperfocal distance is 0.68 m. Focused there, everything from 0.34 m to infinity is acceptably sharp, which is why many such cameras need no focus mechanism at all. Focused at 1 m instead, the sharp zone runs from 0.40 m to infinity.

Machine-vision inspection

A 16 mm f/4 lens on 3.45 µm pixels at a working distance of 0.5 m, with a one-pixel CoC for measurement. The sharp zone is only 487–514 mm, about 27 mm deep. Stopping down to f/8 doubles it to about 54 mm, but at f/8 the Airy disk is about 10.7 µm across, three pixels wide, so the extra depth costs sharpness everywhere. Check the trade-off with the diffraction calculator.

Frequently asked questions

Why do depth-of-field calculators give different answers?

Almost always because they assume a different circle of confusion. Photography calculators default to about 0.025–0.030 mm for full frame, which is far too large for a small sensor. Some also define hyperfocal distance as f² / (N·c) + f instead of f² / (N·c); the difference is one focal length, negligible in practice.

What circle of confusion should I use?

For camera modules, base it on the pixel pitch: about one pixel for measurement and monochrome machine vision, and about two pixels for color sensors in general imaging. The article Choosing a circle of confusion explains why the photography defaults overstate depth of field.

Does a smaller sensor give more depth of field?

At the same focal length, f-number and CoC, no: the optics are identical. In practice a smaller sensor uses a shorter focal length for the same field of view, and depth of field rises steeply as focal length falls, so small-sensor cameras usually have much deeper focus.

What about the image side?

Depth of field is measured in the scene. Its counterpart behind the lens, depth of focus, sets how accurately the sensor must be positioned during assembly. See the depth-of-focus calculator.

Formulas

Hyperfocal H = f² / (N·c). Near limit s·H / (H + s), far limit s·H / (H − s), infinite when the focus distance reaches H. Magnification f / (s − f).

Reverse mode: s = 2·Dn·Df / (Dn + Df), H = 2·Dn·Df / (Df − Dn), N = f² / (H·c). Focal length and CoC are in mm. The diagram uses a compressed scale so infinity fits on the right.

Background reading: Choosing a circle of confusion for small sensors