How the calculation works
The lens is modeled as a thin lens. For an object at distance \(s\) from a lens of focal length \(f\), the magnification and field of view are
where \(p\) is the pixel pitch. To resolve a defect reliably it should span several pixels (typically 3–5), so the smallest detectable defect is that many object-side pixels.
Depth of field
The depth of field is the range of object distances over which the blur stays under the acceptable circle of confusion \(c\) at the sensor. Here \(c\) is set as a number of pixels. The calculator uses the exact thin-lens limits with hyperfocal distance \(H = f^2/(Nc) + f\):
For close-up work (\(s \ll H\)) this reduces to the familiar approximation
A common mistake. The expression \(2Nc(1+m)\) is the image-side depth of focus: how far the sensor can move. Object-side depth of field carries the extra factor \(1/m^2\). At m = 0.14 the two differ by a factor of about 50. Using the wrong one makes a lens look far less forgiving than it is.
Closing the aperture (larger N) increases depth of field linearly, but it also enlarges the diffraction spot and cuts light by \(N^2\). That trade-off is the central compromise in machine vision optics.
Diffraction vs. pixel size
At the sensor, light from a point forms an Airy disk of diameter \(2.44\,\lambda N_w\), where \(N_w = N(1+m)\) is the working f-number. A diffraction-limited lens transmits no detail finer than the cutoff frequency \(1/(\lambda N_w)\) cycles/mm. The sensor can only represent detail up to its Nyquist frequency \(1/(2p)\).
The ratio alone is not the whole story. An ideal lens's MTF falls continuously to zero at the cutoff,
so a ratio of exactly 1 still means zero contrast at Nyquist. A ratio of 1.2 gives about 8 %, and 1.5 gives about 22 %.
- Cutoff ÷ Nyquist ≥ 2: sensor-limited. The optics keep useful contrast (above about 40 %) at the pixel Nyquist frequency. Smaller pixels or more magnification would help, and fine periodic patterns can alias.
- Between 1 and 2: balanced. Both the optics and the pixels limit resolution. Contrast at Nyquist is low, so small defects lose contrast before they lose pixels.
- Below 1: diffraction-limited. The pixels oversample the blur. Opening the aperture (smaller N), if depth of field allows, adds real resolution. Adding pixels does not.
Real lenses reach the diffraction limit only near f/5.6–f/11 and fall short of it at wide apertures because of aberrations. Check the lens MTF at your sensor's Nyquist frequency.
Worked example
A 2/3″ IMX250 camera (3.45 µm pixels, 2448 × 2048) with a 25 mm lens at f/2.8, 200 mm from the part:
- m = 25/175 = 0.143, so the 8.45 × 7.07 mm sensor sees a 59.1 × 49.5 mm field. Each pixel covers 24.2 µm, so a 3-pixel defect is about 72 µm.
- With c = 2 px (6.9 µm), the depth of field is about 2.2 mm. The image-side formula would wrongly give 0.04 mm.
- Nw = 3.2, so the Airy disk at 550 nm is 4.3 µm, about 1.2 pixels. The cutoff-to-Nyquist ratio is 3.9 (ideal-lens MTF at Nyquist ≈ 68 %), so this setup is sensor-limited. To find smaller defects, increase magnification or use smaller pixels. Do not stop down.
For a 100 mm field at 300 mm with the same sensor, the lower panel gives f = 23.4 mm. A standard 16 mm lens gives a 150 mm field. A 25 mm lens needs the part about 321 mm away.
Assumptions and limits
- Thin-lens, paraxial model with a pupil magnification of 1. Real multi-element lenses have separated principal planes and asymmetric pupils, so treat distances as approximate and confirm with the lens vendor's calculator or a test image.
- Lenses have a minimum object distance. A 25 mm lens may not focus closer than 100–200 mm without extension tubes. The "extension" result is the extra lens-to-sensor distance needed beyond infinity focus.
- Telecentric lenses do not follow \(m = f/(s-f)\). Their magnification is fixed and their depth of field is set by the object-side NA.
- Detectability also depends on contrast, lighting, noise, and the algorithm. The pixel-count rule is a starting point, not a guarantee.
References
- E. Hecht, Optics, 5th ed., Pearson (2017), ch. 5 (geometrical optics) and ch. 10 (diffraction).
- J. E. Greivenkamp, Field Guide to Geometrical Optics, SPIE Press (2004).
- Edmund Optics, Imaging Resource Guide (application notes on resolution, depth of field, and lens selection).