Depth of Field Calculator for Machine Vision Lenses

Calculate the total depth of field (DoF) for machine vision lenses — the range of object distances that produce an acceptably sharp image on the sensor.

...

Formulas

Circle of Confusion:
c = pixel_size × multiplier  (µm → mm)

Hyperfocal Distance:
H = f² / (N × c)

Near Depth of Field Limit:
Dnear = u·f·(u − f) / [f² + N·c·(u − f)]

Far Depth of Field Limit:
Dfar = u·f·(u − f) / [f² − N·c·(u − f)]
(= ∞ when denominator ≤ 0, i.e., u ≥ H)

Total Depth of Field:
DoF = Dfar − Dnear

Magnification:
m = f / (u − f)  (thin lens)

Depth of Focus (image side):
δ = 2·N·c·(1 + m)

Assumptions & References

  • Thin lens model is assumed; real lenses may deviate due to aberrations and principal plane separation.
  • The Circle of Confusion (CoC) is set as a multiple of the pixel size — a common machine vision convention. A multiplier of 2 means blur up to 2 pixels is acceptable.
  • All distances are in millimetres; pixel size input is in micrometres.
  • The hyperfocal distance formula H = f²/(N·c) assumes f ≪ H (paraxial approximation).
  • When the object distance equals or exceeds the hyperfocal distance, the far limit of DoF extends to infinity.
  • Depth of focus (image-side) is the tolerance on sensor position for acceptable sharpness.
  • References: Hecht, Optics (5th ed.); Edmund Optics Machine Vision Learning Centre; Ray, Applied Photographic Optics.

In the network