Depth of field is the tolerance your focus actually has on the line: the total height range over which a feature stays sharp enough to detect or measure. Something always spends it — a connector standing proud of the board, a part seated shallow in its tray, a fixture that varies by half a millimetre. You own two controls over it, the aperture ring and the camera position. This guide gives the scaling laws that tie them together, one formula, and one worked board-inspection example that ends in an f-number. After it you can decide on paper whether to stop down, move the camera back, or change the optics.
The decision, stated first
Work the choice in this order and the f-number falls out of the task:
- Fix the field of view from the largest part plus its staging. That fixes magnification, m = sensor width / field of view, and depth of field moves with magnification more than with anything else.
- Write the depth requirement as one number: the full height span the features occupy, tallest feature top down to the lowest surface that must be sharp, plus placement tolerance on both sides, times 1.25.
- Solve for the f-number: N = DOF × m² / (2 × c × (1 + m)), where c is the blur you accept at the sensor. Use one pixel for measuring, two for presence checks.
- Check the diffraction ceiling: keep the Airy disk under two pixels, which at 525 nm means N ≤ 1.6 × pixel size in µm.
- Check the light budget: the strobe or exposure must supply (N / N₀)² times the light of your widest setting, where N₀ is the f-number the exposure was first tuned at.
If step 4 or 5 fails, forcing the iris is the wrong response. Lower the magnification, accept a wider view on the same sensor, or split the station by task. The companion guides on aperture, f-number and depth of field and machine vision optics basics cover the neighbouring ground; this piece stays on the three-way trade.
Committed defaults, so you have a number to argue with: on 3.45 µm pixels under green or white light, presence and assembly stations belong at f/8 to f/11, spending three to six pixels of diffraction blur that edges and barcodes tolerate. Measuring stations belong at f/5.6 or wider and buy flatness with geometry instead of the iris.
The geometry behind the number
Focus is exact at one plane. Every millimetre away from it, the cone of light through the lens opens into a blur circle that grows in proportion to the distance, and depth of field is the range where that circle stays under a size you accept. Write the acceptance as c at the sensor and both sides of the focal plane add up to:
N is the f-number, c the accepted blur circle, f the focal length and WD the working distance. The second line is the handy form at machine-vision magnifications: depth of field grows with the square of working distance and shrinks with the square of focal length. It runs about ±15% at short range, so quote the exact magnification form on paper. Everything you will ever do with depth of field sits in those two lines: aperture linear, working distance squared, magnification squared against you.
Aperture: linear depth of field, quadratic light
Closing the iris is the only control that leaves field of view and working distance alone, which is why it is the first lever you pull. Its price structure is asymmetric:
- Depth of field is linear in f-number: double N and you double the depth.
- Image brightness falls as 1/N²: double N and the station needs four times the light, two stops.
- Diffraction blur is linear in f-number: the Airy disk diameter is 2.44 × λ × N, so each stop multiplies edge blur by 1.41.
| f-number | Depth vs f/2.8 | Light needed | Airy disk at 525 nm | Blur on a 3.45 µm pixel |
|---|---|---|---|---|
| f/2.8 | 1.0× | 1× | 3.6 µm | 1.0 px |
| f/4 | 1.4× | 2× | 5.1 µm | 1.5 px |
| f/5.6 | 2.0× | 4× | 7.2 µm | 2.1 px |
| f/8 | 2.9× | 8× | 10.2 µm | 3.0 px |
| f/11 | 3.9× | 15× | 14.1 µm | 4.1 px |
| f/16 | 5.7× | 33× | 20.5 µm | 5.9 px |
| f/22 | 7.9× | 62× | 28.2 µm | 8.2 px |
Read the f/5.6 row twice. On a 3.45 µm pixel that is the two-pixel diffraction ceiling: below it you trade away resolution the sensor was bought for, above it you get a tall, soft-focus range, which is the standard presence-check compromise. The Airy disk and diffraction limit guide works that side in detail, including the wavelength dependence: at 850 nm the ceiling tightens to roughly N ≤ 1.0 × pixel size in µm.
Lenses print the range you have to spend. The LS-FFL-0567 is a 16 mm, 1.1-inch, 20 MP C-mount lens with an F2.8-22 iris — the whole table above in one ring.
- Type
- Machine vision fixed
- Sensor format
- 1.1"
- Mount
- C-mount
- Resolution
- 16-25 MP
Working distance: the square law and the trap
On the same lens at the same accepted blur, the second formula line makes depth of field grow with the square of working distance. Move a camera from 200 mm out to 280 mm, a factor of 1.4, and the depth doubles. The bill arrives in pixels, not photons: the per-pixel footprint on the object grows in proportion to the distance, so the finest detail carries 1.4 times fewer pixels across it. Sensor brightness hardly moves, because the f-number, not the distance, sets the cone the lens accepts.
That note is the trap. Standing back and fitting a longer lens to keep the same view, a 50 mm where a 25 mm worked, changes nothing in the depth budget: once m is fixed, the exact formula has no distance term left. It buys mechanical room and flatter perspective, nothing else. The guides on choosing a focal length and how sensor size and focal length set the field of view cover landing that pair.
Macro-range lenses show the harsh end of the same law. The LS-FFL-1023 is a 1/2-inch, 0.5x lens with a printed WD of 150 mm and a single F13.4 setting. At 0.5x the m² term dominates: with a one-pixel 3.45 µm criterion, 2 × 13.4 × 0.00345 × 1.5 / 0.25 ≈ 0.55 mm of total depth is all there is. That is why fixed-magnification lenses ship stopped down and reserve spacers and shims for fine focus rather than an iris. Flat targets at a fixed distance are exactly the job this lens class exists for.
- Type
- Machine vision fixed
- Sensor format
- 1/2"
- Image circle
- Up to 8 mm
Worked example: focus across ±2 mm of connector height on a 90 mm board
Inputs, each with its origin:
- Field of view 90 mm — the largest board the station must accept (task input).
- Height span ±2 mm about the nominal plane, connector tops down to board surface, so 4 mm; focus placement repeats to ±0.4 mm. Requirement: (4 + 0.8) × 1.25 = 6.0 mm of total depth.
- Sensor 14.1 mm wide, 3.45 µm pixels, about 4,100 pixels across, a 1.1-inch-class format (example input, not a catalog spec).
- Lens: LS-FFL-0567, a 16 mm C-mount lens whose printed iris runs F2.8-22.
- Light: 525 nm green strobe; line speed 100 mm/s.
Step 1, magnification and distance at the 90 mm view: m = 14.1 / 90 = 0.157, so WD = 16 × (1 + 0.157) / 0.157 ≈ 118 mm. Step 2, the iris-only path: N = 6.0 × 0.157² / (2 × 0.00345 × 1.157) = 6.0 × 0.0246 / 0.00798 ≈ 18.5. The iris reaches f/22, but that spends six stops of light and 8.2 pixels of diffraction blur. Allowed, not wise.
Step 3, the distance path at a sane f-number. Hold f/8 and solve 6.0 = 2 × 8 × 0.00345 × (1 + m) / m², which rearranges to 6m² − 0.055m − 0.055 = 0, so m ≈ 0.101. Then WD = 16 × 1.101 / 0.101 ≈ 175 mm, field of view = 14.1 / 0.101 ≈ 140 mm, pixel footprint = 3.45 / 0.101 ≈ 34 µm, and the depth checks out at 6.0 mm. Motion holds too: 200 µs at 100 mm/s smears 20 µm, 0.6 of a pixel.
The three settings side by side, all meeting the 6.0 mm requirement:
| Setting | WD | Field of view | Light vs f/2.8 | Object-side diffraction blur | 0.5 mm pad spans |
|---|---|---|---|---|---|
| f/22, 16 mm | 118 mm | 90 mm | 62× | 0.18 mm | 23 px |
| f/11, 16 mm | 151 mm | 119 mm | 15× | 0.12 mm | 17 px |
| f/8, 16 mm | 175 mm | 140 mm | 8× | 0.10 mm | 15 px |
Decision: set f/8 at 175 mm. It meets the requirement with three stops of light instead of six, holds edges to 0.10 mm of blur against 0.18 mm at f/22, and still puts 15 pixels across a 0.5 mm pad. Keep f/22 at 118 mm only where the mechanical layout forbids the longer distance, and pay for it in strobe energy. If the task also gauges edges below 0.15 mm, no row above passes and the station goes telecentric.
Telecentric lenses: the same law, a different prize
Nothing in the formula above is entocentric. A telecentric lens obeys the identical scaling, linear in f-number and inverse square in magnification, and its datasheet depth is quoted at a stated blur circle, so compare lenses at equal criteria. What telecentric optics change is what happens inside the depth range: magnification stays constant, so a feature at the top of the height span measures the same as one at the bottom.
Run the entocentric cost with the chosen setting above, 16 mm at 175 mm. A part sitting 2 mm out of plane reads ±2 / (175 − 16) = ±1.3% off: a 10.00 mm feature returns 10.13 mm at one height and 9.87 mm at the other. No f-number fixes that; f/22 keeps both planes in focus and both wrong by different amounts. That measurement drift, not depth of field, is the trigger for telecentric optics — the entocentric versus telecentric comparison and the telecentric lens selection guide walk that decision. For gauging through a height span, a lens like the LS-TCL-2194, a 0.5x, 1-inch C-mount telecentric with 110 mm working distance and a built-in coaxial light port, holds scale where an iris only holds focus.
- Sensor format
- 1"
- Mount
- C-mount
- Image circle
- 11-16 mm
- Type
- Object-side telecentric
When stopping down is the wrong move
Three failures show up on real lines, all from pushing the f-number past a ceiling:
- Small pixels hit the diffraction wall early. The ceiling is about 1.6 × pixel size in µm at 525 nm, so 2.7 µm-class sensors are there before f/4.5. Pair those sensors with lenses shot near wide open, and buy depth with distance or a taller light budget instead of the iris.
- Motion caps your exposure payback. In the example, the stops had to come from the strobe because 100 mm/s allows only 200 µs. On a faster line, 250 mm/s with a 1 ms strobe, the part smears 0.25 mm during exposure; the depth of field is perfect and the image is ruined. Focusing the lens at working distance is the first fix there, aperture the second.
- Sub-pixel edges stop being sub-pixel. Beyond the two-pixel Airy ceiling, edge contrast falls until a sub-pixel fit has nothing to lock onto, and measured dimensions drift with lighting. Gauging stations should live near wide open and buy flatness with telecentric optics or fixturing, not with the iris.
One more option for static parts: focus stacking. Shoot two or three focal planes and combine them; it works when the part does not move and costs less than an optics change on slow stations.
Checks before you order
- The depth requirement written as one number: full height span plus two-sided placement tolerance, times 1.25. A station without that number has no focus spec.
- The f-number solved from N = DOF × m² / (2 × c × (1 + m)), and the candidate lens's iris reaching it with a stop to spare. Run the arithmetic first, then filter the lens finder on focal length and format.
- Airy disk at that f-number under 2 pixels for full-resolution tasks, under 6 for presence tasks: 2.44 × λ × N at your wavelength.
- Strobe headroom of at least (N / N₀)² at the exposure your line speed allows, with exposure held under pixel footprint divided by line speed.
- Sensor format inside the lens's image circle, or the corners pay for the mismatch.
- A plan to focus at the middle of the height span, lock iris and focus ring, and re-check both after mounting — vibration and thermal growth move them.
Run the numbers, then bind camera, lens and light together in the lens configurator; when the two ceilings conflict, bring your arithmetic to the applications desk and we will size the station with you.
Questions
Is it better to stop down or to move the camera back for more depth of field?
Stop down first, while the Airy disk stays under about two pixels: aperture depth costs no geometry, and light is easier to replace than pixels. Past that ceiling, move the camera back. On the same lens, 1.4 times the working distance doubles depth of field, at the price of 1.4 times coarser pixels on the part. If both levers are maxed out, the magnification itself is wrong for the task.
Why did a longer working distance not give me more depth of field?
Because the field of view did not change. Doubling the distance from 200 mm to 400 mm while swapping a 25 mm lens for a 50 mm keeps magnification constant, and at constant magnification depth of field depends only on f-number and the blur you accept. The working-distance square law applies when the focal length stays put and the field of view grows with the distance.
How much light do I lose stopping from f/2.8 to f/16?
About 33 times, five stops, from (16 / 2.8) squared. Pay it with strobe energy where the line allows, or with exposure time when the part is static: 500 µs at f/2.8 becomes 16.5 ms at f/16, which only static stations can afford. Gain can cover the gap, but it lifts noise with the signal, so treat it as the last source rather than a free one.
Do telecentric lenses have deeper depth of field than ordinary lenses?
The scaling with f-number is the same for both, so do not expect a telecentric to win the depth budget outright; check the printed depth range and the blur criterion it is quoted at before comparing two datasheets. The real difference is inside the range: magnification stays constant, so parts measure the same at any height within it. An entocentric lens reading a part 2 mm off plane at 300 mm with a 50 mm focal length swells the reading about 0.8%; a telecentric holds scale.
How do I set the depth-of-field requirement before picking a lens?
Measure the full height span first: tallest feature top down to the lowest surface that must be sharp, not just part thickness. Add the fixture's placement tolerance on both sides, then apply about 25% margin. Connectors standing 4 mm above a board held to ±0.5 mm give 4 + 1 = 5 mm, so the requirement is 5 × 1.25 ≈ 6 mm of total depth, and that is the number the f-number must deliver.
Does a bigger sensor give more depth of field at the same field of view?
Less, not more. Magnification is sensor width divided by field of view, and depth of field falls with the square of magnification: doubling sensor width at a fixed field of view quarters the depth at the same f-number. The trade runs the other way. A smaller sensor or a wider view deepens focus, which is why budget stations sometimes keep a modest sensor and stop down.

