Machine Vision Lens Calculator

Choose a camera sensor and a lens to see what the camera will see: how large an area it covers (the field of view), how small a defect it can resolve, and how much height variation stays sharp (the depth of field). The page also shows whether the lens or the pixels limit the finest detail, and the lower panel finds the focal length you need for a given field of view and distance.

Key terms
Field of view (FOV)
The width and height of the area on the part that one image covers. Spreading the same pixels over a larger field makes each pixel cover more of the part.
Object distance
How far the part is from the lens (the vision system configurator calls it the working distance). Here it is measured from the lens’s front principal plane, an optical reference point, so it differs somewhat from the working distance that lens makers quote from the front of the lens barrel.
Focal length
The lens’s main specification, printed on the barrel (25 mm, for example). From the same distance, a longer focal length sees a smaller area in more detail.
Magnification
The size of the image on the sensor divided by the true size on the part. Most machine vision setups work well below 1; the default setup here is 0.14.
Pixel pitch
The spacing between neighboring pixels on the sensor, listed in the camera datasheet as the pixel size, in micrometers (µm).
f-number
The aperture setting on the lens, written f/2.8, f/8, and so on. A larger number means a smaller opening: more depth of field, but less light and more blur from diffraction.
Depth of field
How far the part can move toward or away from the camera and still look sharp. “Sharp” means the blur stays within the acceptable blur you set, in pixels.
MTF at Nyquist
The share of contrast the lens keeps on the finest pattern the pixels can record (one dark and one light line per two pixels). Near 0 % that detail is lost, however many pixels it spans.

Camera and lens

392 area-scan sensors from ten makers, grouped by maker and series. Each array is the maker’s recommended recording size where one is stated (what most cameras output by default), otherwise the effective or active array; camera makers sometimes crop further, so check the camera datasheet. To size a whole system, try the vision system configurator.

px
px

The pixel size and the pixel counts (the resolution) are in the camera datasheet. A sensor preset fills in all three.

The focal length is printed on the lens. Object distance is measured from the lens’s front principal plane, not from the front of the barrel as in lens datasheets; the two can differ by several millimeters or more.

f/#

The aperture setting on the lens. A larger number gives more depth of field, but less light and more diffraction blur.

The color of the light: LEDs peak near 470 nm (blue), 525 nm (green), 625 nm (red), or 850 nm (near infrared). Use 550 nm for white light.

px

The largest defocus blur, in pixels, that still counts as sharp (the circle of confusion). Use 1–2.

px

2 is the sampling minimum; 3–5 px for reliable detection, 10 or more to measure.

Results

Field of view (H × V)—
Magnificationm = f/(s − f)—
Sensor size—
Pixel size on the object—
Smallest detectable defect— Pixels across a defect × pixel size on the object: a first estimate. Contrast, lighting, and noise decide what is really detectable.
Depth of fieldobject side—
Working f-numberN(1 + m)—
Airy disk diameter2.44 λ Nw—
Optical cutoff ÷ sensor Nyquist— 2 or more: the pixels limit the finest detail. Below 1: the lens does, and more pixels will not help.
Diffraction MTF at sensor Nyquist— Upper bound for an ideal lens at this working f-number; aberrations and the pixels themselves lower the contrast in the image. Lens makers’ rule of thumb: about 10 % contrast in the image to detect detail, and 20 % or more as a safer target.
Lens extension beyond fm·f— Extra lens-to-sensor spacing beyond infinity focus. If the lens cannot focus this close, a spacer ring (extension tube) adds it.

Which focal length do I need?

2/3″ IMX250: 8.45 mm. 1″ IMX183: 13.1 mm. 1/1.8″ IMX252: 7.07 mm.

Lens choice

Required focal lengthf = m s/(1 + m)—
Required magnification—
Shorter standard lens (wider view)—
Longer standard lens (needs more distance)—

Standard machine vision focal lengths: 4, 5, 6, 8, 12, 16, 25, 35, 50, 75, and 100 mm.

How it is calculated

The lens is modeled as a thin lens. For an object at distance \(s\) from the front principal plane of a lens of focal length \(f\), the magnification (image size over object size) and the field of view are

\[ \begin{gathered} m = \frac{f}{s - f}, \quad \text{FOV} = \frac{\text{sensor size}}{m}, \\[6pt] \text{pixel on object} = \frac{p}{m}, \end{gathered} \]

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 geometric blur at the sensor stays under the acceptable circle of confusion \(c\) (a diameter, set here as a number of pixels). This is not the laser “depth of focus” of the beam calculators, which is the distance over which a focused spot grows by a set fraction. For a thin lens with the aperture stop at the lens, the near and far limits follow exactly from the hyperfocal distance \(H = f^2/(Nc) + f\):

\[ \begin{gathered} s_\text{near} = \frac{s(H - f)}{H + s - 2f}, \\[8pt] s_\text{far} = \frac{s(H - f)}{H - s}, \\[8pt] \text{DOF} = s_\text{far} - s_\text{near}. \end{gathered} \]

For close-up work (\(s \ll H\)) this reduces to the familiar approximation

\[ \mathrm{DOF} \approx \frac{2\,N\,c\,(1 + m)}{m^2}. \]

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 the depth of field in proportion to N in this approximation, but it also enlarges the diffraction spot in proportion to N and cuts the light on the sensor in proportion to \(1/N^2\): each full stop (N × √2) halves it. 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 whose diameter to the first dark ring is \(2.44\,\lambda N_w\), where \(N_w = N(1+m)\) is the working f-number (for a lens with equal entrance and exit pupils). In incoherent light, a diffraction-limited lens with a circular aperture transmits no detail finer than the cutoff frequency \(1/(\lambda N_w)\), in cycles per millimeter when \(\lambda\) is in millimeters. The sensor can only represent detail up to its Nyquist frequency \(1/(2p)\), one cycle per two pixels.

The ratio alone is not the whole story. An ideal lens’s MTF falls continuously to zero at the cutoff,

\[ \begin{gathered} \mathrm{MTF}(\nu) = \tfrac{2}{\pi}\bigl[\arccos\nu - \nu\sqrt{1-\nu^2}\bigr] \\[6pt] \nu = \frac{f_\text{Nyquist}}{f_\text{cutoff}}, \end{gathered} \]

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 %.

Real lenses fall short of the diffraction limit, most of all at wide apertures, where aberrations dominate, so these MTF values are upper bounds. Check the lens maker’s MTF curve 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:

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

References

Primary sources and standards

  1. B. Jähne, Digital Image Processing and Image Acquisition, 7th ed., Springer (2026), doi:10.1007/978-3-032-04806-6, secs. 3.4.2 and 3.4.4 (image scale, the imaging equation, depth of focus and depth of field), 3.5.2–3.5.3 (the MTF of diffraction-limited optics), and 5.2.3 (the sampling theorem).
  2. J. E. Greivenkamp, Field Guide to Geometrical Optics, SPIE Press (2004), doi:10.1117/3.547461 (f-number, depth of focus and depth of field, hyperfocal distance).
  3. J. E. Greivenkamp, “Camera Systems,” sec. 17 of the course notes for OPTI 201/202, Geometrical and Instrumental Optics, University of Arizona (2018), PDF (depth of focus, and the near and far limits and hyperfocal distance in the small-blur approximation, for a thin lens with the stop at the lens; free).
  4. G. D. Boreman, Modulation Transfer Function in Optical and Electro-Optical Systems, SPIE Press (2001), doi:10.1117/3.419857, secs. 1.5 (the diffraction MTF of a circular aperture and its cutoff) and 2.1–2.2 (pixel footprint, sampling, the Nyquist frequency, and aliasing).
  5. C. E. Shannon, “Communication in the presence of noise,” Proc. IRE 37, 10–21 (1949), doi:10.1109/JRPROC.1949.232969 (the sampling theorem behind the Nyquist frequency 1/(2p)).
  6. C. Steger, M. Ulrich, and C. Wiedemann, Machine Vision Algorithms and Applications, 2nd ed., Wiley-VCH (2018), ISBN 978-3-527-41365-2, secs. 2.2.2–2.2.4 (lens model, pupils, depth of field, telecentric lenses) and 2.3.3 (color cameras and the Bayer filter).
  7. B. E. Bayer, “Color imaging array,” U.S. Patent 3,971,065 (1976), patents.google.com/patent/US3971065A (the color filter layout: green on every other pixel, red and blue on alternate rows).
  8. E. Hecht, Optics, 5th ed., Pearson (2017), ch. 5–6 (geometrical optics) and ch. 10 (diffraction).

Textbooks

Free introductions