Depth of Field in Machine Vision: Aperture, Working Distance, and the Circle of Confusion
How aperture, focal length, working distance, and circle of confusion set the sharp zone, when stopping down stops helping, and how depth of focus differs from depth of field.
Depth of field (DOF) in machine vision is the range of object distances that produce acceptably sharp images on the sensor. Four variables control it: f-number, focal length, working distance, and the permissible circle of confusion, which machine vision sets from pixel pitch rather than photographic convention. Shorter focal lengths and longer working distances extend DOF quadratically; stopping down helps linearly until diffraction cancels the gain. Run your own numbers in the Commonlands camera depth of field calculator.
What is depth of field in machine vision?
Depth of field is the range of object distances over which a lens holds blur below the permissible circle of confusion on the sensor. In machine vision the blur limit comes from pixel pitch, not print sharpness, so practical DOF is far shallower than photography rules of thumb suggest. Any published DOF figure is unusable until you know the CoC behind it, and datasheets rarely state one.
Strictly, the circle of confusion does not define depth of field. It is a proxy that yields a theoretical DOF for a diffraction-limited lens at the working F-number, which turns a focus question into arithmetic. The real usable range depends on how the lens's MTF at your feature's spatial frequency holds through focus, which no single blur number captures. Commonlands can provide measured DOF tables for each of its lenses on request.
F-number and CoC act on DOF linearly, while the working-distance-to-focal-length ratio acts quadratically, so geometry is the strongest lever. That is also why a higher-resolution sensor, which tightens the CoC, shrinks the working DOF even though nothing about the lens changed. The working distance guide covers how WD fits the rest of the optical stack.
What determines depth of field in a machine vision system?
Four variables set depth of field: f-number, focal length, working distance, and the permissible circle of confusion. DOF grows linearly with f-number and CoC, and with the square of the working-distance-to-focal-length ratio. Focal length and working distance are the strongest levers because they act quadratically.
Aperture (f-number)
Closing the iris shrinks the light cone and the blur circles from out-of-focus points. Doubling the f-number roughly doubles DOF, but each full stop halves the light, so two stops cost a factor of four in exposure. Many M12 lenses run at a single fixed f-number, so aperture is set at selection. An adjustable-iris C-mount lens such as the Commonlands CIL544 lets you tune it at the bench. See the f-number guide.
Focal length
DOF scales with the inverse square of focal length, the strongest single lever during selection: a 6mm lens holds roughly 7 times more DOF than a 16mm lens at the same working distance and aperture, since (16/6)² ≈ 7.1. The cost is pixel density, since a shorter lens spreads pixels over a wider field of view. If the feature size needs the longer lens, the extra DOF must come from aperture or working distance. See the focal length selection guide.
Working distance
DOF scales with the square of working distance, so moving the camera from 300mm to 600mm at constant focal length and aperture roughly quadruples it. Restoring the field of view needs a longer focal length, which gives some of the gain back, so model the two together. Early on, the camera can move and a DOF problem is cheap to fix. Once the mechanics are committed, WD is fixed and the remaining levers are optical.
Permissible blur (circle of confusion)
Relaxing the CoC raises the calculated DOF, but the physical blur does not change. Only the label of what counts as acceptable moves. The right CoC is the largest blur the algorithm still tolerates at full reliability. The circle of confusion section below gives per-task starting values.
Working distance limits are not on every datasheet, and published DOF figures rarely state their CoC assumption. When comparing candidate lenses, request the assumed CoC or recompute DOF from f-number, focal length, and your own pixel-pitch CoC so the comparison is like for like.
Does stopping down the aperture increase depth of field?
Stopping down increases depth of field roughly linearly with f-number, but it costs light and eventually adds diffraction blur that outweighs the gain. For sensors with 1.5-2µm pixels, diffraction typically becomes visible around F/2.8-F/4 and dominates by F/5.6-F/8.
Light loss
Each full stop halves the light, so going from F/2.8 to F/11, four stops, drops it to a sixteenth at the same exposure. Strobe power must rise or the exposure must lengthen, which risks motion blur on moving targets, and eventually the illumination system hits its power limit. This cost is often payable because illumination is programmable, but it must be budgeted, not assumed.
Diffraction
Light passing a small aperture diffracts. The point image on the sensor becomes an Airy disk whose diameter grows with f-number:
On a sensor with 1.85µm pixels, an F/8 Airy disk spans nearly 6 pixels, and that blur floor sits under the entire image, so closing the iris past this point erases the resolution the extra DOF was meant to protect. A 3.45µm-pixel sensor tolerates roughly F/5.6-F/8; a 1.5µm-pixel sensor loses pixel-scale contrast near F/5.6. The diffraction limit guide covers the resolution side.
The practical operating band for typical machine vision sensors is F/2.8-F/8. Before going past F/8, compute the Airy disk against your pixel pitch. Commonlands can supply a measured through-focus MTF curve for a candidate lens, so the tradeoff is not left to the geometric estimate.
What circle of confusion should I use in machine vision?
Use a circle of confusion derived from pixel pitch, typically 1-2 pixel pitches depending on the task. Photographic CoC conventions run several times too large for machine vision sensors. Pixel pitch comes from the sensor datasheet, not the format name. See the sensor size guide.
The machine vision criterion is CoC = k × pixel pitch, where k is the number of pixels of blur the task tolerates:
| Task | Typical CoC (pixels) | Rationale |
|---|---|---|
| Metrology, dimensional measurement | 1 | Blur past 1 pixel shifts edge locations at the measurement threshold |
| Fine surface inspection | 1 | Defects may span only 1-2 pixels; blur masks them |
| Barcode, 2D code, OCR | 1-2 | Narrowest bar, cell edge, or stroke must stay resolved |
| Pick-and-place localization | 1-3 | Placement accuracy sets the tolerance |
| Presence detection, robot navigation | 2-4 | Features are large relative to pixel scale |
The definitive test is empirical: expose the real algorithm to controlled defocus at the working aperture and find the blur level where output error crosses the acceptance threshold. Enter that value, not a photography default, into the Commonlands depth of field calculator.
What is hyperfocal distance in machine vision?
Hyperfocal distance is the closest focus distance at which the far depth-of-field limit reaches infinity: H = f² / (N × c). Focused at H, everything from H/2 to infinity stays within the circle-of-confusion budget. It suits navigation and monitoring cameras with variable object distances, not fixed-distance inspection.
Because H scales with f², focal length dominates. With c = 3.7µm, two pixel pitches on a 1.85µm sensor, the Commonlands CIL821 2.1mm M12 lens at F/2.4 gives H = 2.1² / (2.4 × 0.0037) ≈ 0.50m. Everything from about 0.25m to infinity then holds within budget, a workable fixed-focus setup for a robot navigation camera. The CIL160 16mm at F/1.9 gives H ≈ 36m, near limit around 18m. Focus it at the working plane instead.
Hyperfocal focus fits AMR and drone navigation, wide-area monitoring, and factory-set fixed-focus modules, where object distances vary and no plane deserves peak sharpness. It is the wrong strategy for inspection, metrology, and barcode reading: at H/2 blur equals the full CoC, a pure liability when the target sits at one controlled distance. See the focusing guide for setting focus at either target.
The calculation is only as good as its CoC: tightening c from 6µm to 3µm doubles H and can push the near limit beyond the closest object the camera must see. Before committing a factory focus setting, verify the algorithm's detection rate on images captured at H/2, where blur sits at the full CoC limit.
What is the difference between depth of focus and depth of field?
Depth of field is the object-side tolerance: how far the scene can move while lens and sensor stay fixed. Depth of focus is the image-side tolerance: how far the sensor can shift along the optical axis before blur exceeds the permissible circle of confusion, about 2 × f-number × CoC in total. They are conjugates, not synonyms.
| Parameter | Depth of field | Depth of focus |
|---|---|---|
| Side of the system | Object side | Image side (sensor plane) |
| What moves | Object distance | Sensor position |
| Typical range | Millimeters to meters | Tens of micrometers |
| Failure signature | Parts at the wrong distance are blurry, others sharp | Entire image uniformly soft after assembly |
The image-side window stays near 2 × N × c regardless of magnification, about 40µm at F/4 with c = 5µm, while object-side depth of field grows as magnification falls. A low-magnification system with generous depth of field therefore still carries the same tens-of-micrometers sensor-placement budget.
That window must absorb every sensor-position error in the build: PCB thickness variation, package height, flange tolerance, shims, and thermal drift, which can reach tens of micrometers in compact assemblies. A Commonlands lens that passes bench testing can still produce soft images after integration, so validate focus in the assembled camera at the working aperture, not on a bench at nominal flange distance.
Which lenses fit depth-of-field-critical applications?
Short focal lengths give forgiving DOF at fixed apertures, long focal lengths trade DOF for pixel density, and adjustable-iris C-mount lenses let the aperture be tuned on site. The three lenses below are examples of those cases, not a complete list: check the machine vision lens collection for current options. Commonlands ships in-stock lenses same day on orders placed before 12 PM PST.
We ranked them by how much control each gives over the depth-of-field budget, not by resolution. The adjustable-iris CIL544 leads because you can trade DOF against diffraction at the bench, while the two fixed-aperture M12 lenses lock that decision at selection time.
| Rank | Lens | Mount | EFL | Aperture | When to choose it | Product |
|---|---|---|---|---|---|---|
| 1 | CIL544 | C-mount | 25mm | F/1.8 adjustable iris | When you need to sweep the aperture at the bench to find the DOF and diffraction optimum on a 1.1" 20MP sensor. | 25mm C-mount lens |
| 2 | CIL160 | M12 | 16mm | F/1.9 to F/5.6 variants | Locked-aperture production builds that want high pixel density and hold parts at a fixtured working distance. | 16mm M12 lens |
| 3 | CIL059 | M12 | 5.9mm | F/1.7, F/2.8, F/4.0, F/5.6 fixed variants | Short-EFL layouts that need forgiving DOF; the four fixed-aperture variants let the DOF budget choose the F-number without an iris. | Low distortion 6mm M12 lens |
Frequently asked questions
What is the circle of confusion in machine vision?
The circle of confusion is the maximum blur-spot diameter on the sensor that an application still treats as in focus. In machine vision it is an engineering tolerance set from pixel pitch and algorithm tolerance, typically 1-2 pixel pitches, far tighter than photographic conventions calibrated to human print viewing.
What is hyperfocal distance in machine vision?
Hyperfocal distance is the closest focus distance at which the far depth-of-field limit extends to infinity for a given lens, aperture, and circle of confusion. Focused at the hyperfocal distance H = f² / (N × c), everything from H/2 to infinity stays within the blur budget. It suits navigation and monitoring cameras, not fixed-distance inspection.
What is depth of focus in machine vision?
Depth of focus is the allowed displacement of the image sensor along the optical axis before blur exceeds the permissible circle of confusion. It is an image-side tolerance, approximately 2 × f-number × CoC in total, typically tens of micrometers. Depth of field is the corresponding object-side tolerance; the two are not interchangeable.
How do I increase depth of field in machine vision?
Use a shorter focal length, increase the working distance, or stop down the aperture, in that order. The first two extend DOF quadratically without cutting light. Stopping down works linearly but costs illumination and eventually adds diffraction blur. Model the options with the Commonlands depth of field calculator before changing hardware.
When does diffraction cancel the benefit of a smaller aperture?
When the Airy disk approaches the sensor pixel pitch. The Airy disk diameter is approximately 2.44 × wavelength × f-number: about 10.7µm at F/8 in 550nm light, which spans nearly 6 pixels on a 1.85µm sensor. Larger pixels, such as 3.45µm, tolerate higher f-numbers before diffraction dominates.
Should I focus at the working plane or hyperfocal distance?
Focus at the working plane when the target sits at a defined, repeatable distance, which covers most inspection systems. Focus at the hyperfocal distance when object distances vary continuously and no single plane dominates, as in robot navigation, wide-area monitoring, and fixed-focus embedded cameras.
Need a DOF budget reviewed?
Commonlands manufactures M12 and C-mount lenses for machine vision, with MTF testing as part of production quality control. Send the San Diego engineering team your working distance, part-height variation, and sensor, and we will recommend a lens and operating aperture. In-stock samples ship same day on orders placed before 12 PM PST.



