Lenses & opticsExplainer

Aperture f-number and depth of field in machine vision cameras

How f-numbers work in machine vision: what one stop costs in light, how aperture sets depth of field, where the 1/3-2/3 rule holds, and the aperture to pick.

LumaSpec Vision12 min read Share on LinkedIn

On this page 9 sections
  1. 01What does the f-number on a vision lens mean?
  2. 02How much light do you lose per f-stop?
  3. 03How does the aperture set depth of field?
  4. 04Is depth of field really 1/3 in front and 2/3 behind focus?
  5. 05What aperture keeps a part with ±20 mm height variation sharp?
  6. 06How far can you stop down before diffraction wins?
  7. 07Does your camera have a fixed or adjustable aperture?
  8. 08What should you check before you lock the aperture?
  9. 09Questions

Every machine vision lens hands you one control that trades light for sharp range: the aperture. Open it wide and the image is bright, but only a shallow slice of the part holds focus. Stop it down and that slice deepens, while the sensor collects fewer photons and diffraction starts to smear fine edges. This explainer gives you the f-stop arithmetic — what one stop costs in light, how depth of field follows the f-number, where the 1/3-in-front rule really holds — and finishes with the aperture to set on a part with real height variation, on an area scan camera, a board camera or the 2D channel of a 3D camera.

What does the f-number on a vision lens mean?

The f-number N is the focal length divided by the entrance pupil diameter, N = f/D, so a 35 mm lens at f/2.8 has a 12.5 mm pupil — 35/12.5 = 2.8 — and a lower f-number means a physically larger opening.

That inverse direction is the whole confusion: f/2.8 is a wider hole than f/8. The number is a ratio, not a diameter, so the same f-number on a shorter lens means a smaller hole in millimetres: f/2.8 on a 16 mm lens is a 5.7 mm pupil (16/2.8).

Nearly every machine vision lens marks the standard f-number series: the powers of the square root of two — f/1.4, f/2, f/2.8, f/4, f/5.6, f/8, f/11, f/16, f/22 and f/32. Each value is 1.414 times the one before it, and because pupil area scales with the square of diameter, every step halves the area and the light together. Count stops between any two settings as n = 2·log₂(N₂/N₁): f/2.8 to f/16 is 2·log₂(5.71) ≈ 5 stops.

Aperture Stops closed from f/1.4 Pupil area vs f/1.4 Depth of field vs f/1.4
f/1.4 0 1× 1×
f/2 1 1/2 1.4×
f/2.8 2 1/4 2×
f/4 3 1/8 2.9×
f/5.6 4 1/16 4×
f/8 5 1/32 5.7×
f/11 6 1/64 8×
f/16 7 1/128 11.4×
f/22 8 1/256 16×
f/32 9 1/512 22.9×

The last column holds for any lens at fixed geometry, because the sharp range grows in step with N.

How much light do you lose per f-stop?

One full stop halves the light: closing from f/2.8 to f/4 gives the sensor half the photons, so you hold the same grey levels by doubling exposure time or adding 6 dB of gain.

Both compensations cost you. Doubling exposure time doubles motion blur — a part moving 100 mm/s smears 0.1 mm in a 1 ms exposure and 0.2 mm at 2 ms — and gain amplifies the image you already have without creating a single photon, so noise rises with it. The aperture is your brightness control at fixed exposure; on a board camera, M12 lens light gathering at the same focal length is decided by exactly this f-number.

For the other two legs of the triangle, automatic iris, exposure and gain control in machine vision covers the control loop, and when the aperture you need leaves you photon-starved, low-light camera selection by EMVA data shows how to compare sensors on measured noise rather than adjectives.

How does the aperture set depth of field?

Depth of field is proportional to the f-number: closing one stop doubles the sharp range, so stepping from f/4 to f/8 — two stops — buys four times the depth of field at one quarter of the light.

Depth of field is the band of part distances whose blur stays under a limit you choose, the circle of confusion c. Machine vision sets that limit from the pixel: 2 pixels for measurement and code reading, 4 pixels when locating features is enough. With focal length f, focus distance s and aperture N:

H = f² / (N · c) near = H · s / (H + (s − f)) far = H · s / (H − (s − f)) DOF ≈ 2 · N · c · s² / f² when s is well under H

H is the hyperfocal distance: focus there and everything from H/2 to infinity reads sharp. The short approximation lands within about 1% at one tenth of H, which covers most inspection stations. The scaling is worth memorising: the sharp zone doubles with the blur budget c, doubles per stop closed, and shrinks with the square of magnification — the reason macro work has so little of it.

Depth of field around the focus plane Light from the lens converges on the focus plane. In front of and behind it, each point spreads into a blur circle; the zone where that blur stays below about a pixel or two is the depth of field. A smaller aperture gives a narrower cone and a deeper zone.depth of fieldfocus planeapertureoutside it, pointsblur into circleswide aperture: steep cone, shallow zonesmall aperture (high F#): deeper zone
Depth of field around the focus plane. Light from the lens converges on the focus plane. In front of and behind it, each point spreads into a blur circle; the zone where that blur stays below about a pixel or two is the depth of field. A smaller aperture gives a narrower cone and a deeper zone.

Two refinements complete the picture. At magnification m the working f-number is N·(1+m), so a 0.5× shot at f/8 really operates at f/12, at 44% of the light the ring suggests. And an entocentric lens changes magnification across its depth of field, while telecentric lenses hold magnification constant through theirs — often the cleaner cure for height variation than any iris setting.

Is depth of field really 1/3 in front and 2/3 behind focus?

Only at one third of the hyperfocal distance: closer in, the split moves toward 50/50, and as you approach H the rear limit stretches to infinity.

From the formulas above, the front and rear shares compare as (H − s)/(H + s). Evaluate that ratio: at s = H/10 the split is 45/55, effectively centred; at s = H/3 it is exactly one third in front and two thirds behind, which is where the rule of thumb comes from; at s = H/2 the front share is down to a quarter; at s = H the far limit is gone to infinity. Inspection stations focus at a small fraction of H — hundreds of millimetres against tens of metres — so treat the zone as symmetric and place your focus point accordingly.

What aperture keeps a part with ±20 mm height variation sharp?

Stop to f/8 with a 4-pixel blur budget: on a 2/3" sensor with 3.45 µm pixels behind a 35 mm lens at 500 mm, that holds about 42 mm of height sharp with diffraction still inside the allowance.

Work the numbers for a station that must image a 110 mm part whose height varies by ±20 mm. A 2/3" sensor is 8.8 mm wide, or 2,551 pixels at 3.45 µm. At a 500 mm working distance a 35 mm lens gives magnification m = f/(s − f) = 35/(500 − 35) = 0.075, so the field of view is 8.8/0.075 = 117 mm — the part fits with margin. Each pixel then covers 3.45/0.075 = 46 µm of the object, the quantity the object-space pixel size from magnification guide works through in detail.

The LS-FFL-0679 is a 35 mm, 2/3", 6 MP C-mount machine vision lens.

Machine vision lenses35 mm, 2/3", 6 MP, C-mount machine vision lens (LS-FFL-0679)LS-FFL-0679
Type
Machine vision fixed
Sensor format
2/3"
Mount
C-mount
Resolution
6-10 MP
$219.00View partBuild a system with it

Set c to 4 pixels, 13.8 µm. The hyperfocal distance at f/8 is H = 35²/(8 × 0.0138) = 1225/0.1104 = 11,098 mm. The near limit is 11,098 × 500/(11,098 + 465) = 480 mm, the far limit is 11,098 × 500/(11,098 − 465) = 522 mm, so the sharp band is 42 mm — 20 mm in front of focus, 22 mm behind, symmetric as predicted because 500 mm is H/22. The part needs 40 mm: focus at the middle of its height band and the f/8 zone covers it.

Against a 2-pixel budget the same station needs f/16, and there the geometry stops telling the truth:

Aperture Depth of field at c = 2 px Airy disk at 550 nm Airy disk in 3.45 µm pixels
f/2.8 7.4 mm 3.8 µm 1.1 px
f/4 10.5 mm 5.4 µm 1.6 px
f/5.6 14.7 mm 7.5 µm 2.2 px
f/8 21.0 mm 10.7 µm 3.1 px
f/11 28.9 mm 14.8 µm 4.3 px
f/16 42.0 mm 21.5 µm 6.2 px

At f/16 the geometric zone is 42 mm, but diffraction spreads every point in it over 6.2 pixels — sharp only against a budget you have already broken. f/8 with the 4-pixel budget is the workable setting.

Count the light as well: f/2.8 to f/8 is three stops, one eighth of the photons. An exposure of 1 ms at f/2.8 needs 8 ms at f/8, and at 100 mm/s of conveyor that is 0.8 mm of smear — 17 object pixels. Hold the 1 ms exposure with a light pulse, or take +18 dB of gain and its noise. The decision, restated: f/8, 4-pixel budget, focus mid-band, pulse the light.

Depth of field and diffraction
Units
Depth of field
– mm
About the focus plane
– mm
Diffraction limit
– F/#
Blur limit
– µm
Diffraction spot
– µm
At this F-number
–

DOF ≈ 2 × N × c × (1 + m) / m², c = allowed blur × pixel size. Diffraction spot (Airy disk) ≈ 2.44 × wavelength × N × (1 + m); past the diffraction limit it is larger than the blur you allowed.

Browse lenses by aperture and format Open the full calculator

How far can you stop down before diffraction wins?

The Airy disk grows as 2.44·λ·N — 1.34 µm of diameter per f-number unit at 550 nm — and the sharp range grows at exactly the same rate, one to one with N, so the trade only pays while the blur stays inside your budget.

Commit the floor to memory: keep the aperture at or below about 1.5 × the pixel size in micrometres for a 2-pixel budget. That is f/4 on 2.9 µm pixels, f/5.6 on 3.45 µm, f/8 on 5.5 µm and f/11 on 9 µm. A 4-pixel budget doubles the allowance, which is exactly how the f/8 setting above stays legitimate. The full story, including what the Airy disk does to MTF, is in diffraction limit and aperture effects in vision lenses.

The lens must also resolve what the sensor samples, at the aperture you actually set — match the printed resolution class to the sensor's pixel count. For small pixels, choose glass that stays sharp while stopped down. The LS-FFL-0567 is a 16 mm, 1.1", 20 MP C-mount lens with an aperture range of F2.8-22.

Machine vision lenses16 mm, 1.1", 20 MP, C-mount machine vision lens, F2.8-22, <0.3% distortion (LS-FFL-0567)LS-FFL-0567
Type
Machine vision fixed
Sensor format
1.1"
Mount
C-mount
Resolution
16-25 MP
$679.00View partBuild a system with it

That F2.8-22 range spans six stops of the standard series: six halvings of light traded, stop by stop, for sharp range.

Does your camera have a fixed or adjustable aperture?

Check before you plan exposure: a C-mount machine vision lens has a mechanical iris ring you set and lock, while board cameras and many 3D cameras ship with a fixed aperture chosen by the maker, and a few 3D models expose a software-adjustable internal iris.

On C-mount glass the iris is a commissioning decision. Set it, then fix it: a ring that drifts moves exposure and depth of field together, so use the locking screw covered in lens locking screws: focus, aperture and enclosure clearance. A fixed-aperture system pushes every brightness adjustment onto exposure time, gain and lighting — know which kind you have before the fixture is built.

On a 3D camera, the depth channel runs on projector or laser exposure, but the 2D texture channel obeys the same f-stop arithmetic as any area scan camera. When the texture image is dim or its depth of field is short, the aperture and the formulas above are where the answer sits.

Any of the C-mount area scan cameras pairs with a lens that has an iris ring:

Area scan camerasHikrobot MV-CH120-11UC 12 MP Area Scan Camera, USB3, IMX304, High-speed version, ColorMV-CH120-11UC
Sensor format
1.1"
Lens mount
C-mount
$2,339.00 · quotedView and quote
Area scan cameras12 MP GigE area scan camera, IMX226, 1/1.7" rolling shutter, 9 fps (LS-CMR-0053)LS-CMR-0053
Sensor format
1/1.7"
Lens mount
C-mount
$560.00View part

The MV-CH120-11UC combines a 1.1" sensor with a global shutter; the LS-CMR-0053 is a 12 MP GigE camera with a 1/1.7" rolling shutter.

What should you check before you lock the aperture?

Run the depth-of-field numbers at the worst-case part position, set the blur budget by task, check the diffraction floor for your pixel size, then focus mid-band and lock the iris.

  • Compute the sharp zone at the nearest and farthest surface the part can present, not at the nominal distance.
  • Set c by task: 2 pixels for measurement and code reading, 4 pixels for presence and coarse features.
  • Check the diffraction floor: keep N at or below about 1.5 × pixel size in µm for a 2-pixel budget.
  • Match the lens's printed resolution to the sensor's pixel count at the aperture you will actually set.
  • Budget exposure at 2× time or +6 dB gain per stop closed, and check motion smear against the object-side pixel.
  • Focus at the middle of the height band, then tighten the focus and iris locking screws.
  • On a 3D camera, set the 2D channel's aperture for texture sharpness and treat depth-channel exposure separately.

When the arithmetic lands between focal lengths or formats, the lens finder filters machine vision lenses by sensor format, mount and resolution, the lens step of the configurator walks the full camera-lens-light trade-off, and the contact page takes aperture and depth-of-field questions before you order.

Questions

Does changing the f-number change the field of view?

No. Field of view is set by sensor size, focal length and working distance; the aperture changes only brightness, depth of field and diffraction blur. Two side effects are real but small: stopping down reduces vignetting at the corners, and at macro magnifications the effective working f-number rises, trimming the light a little further. The framing itself does not move.

Why do aperture markings jump 2.8, 4, 5.6, 8 instead of round numbers?

The series is the powers of the square root of two: 2, 2.8, 4, 5.6, 8, 11, 16, 22, 32. Each value is 1.414 times the one before it, which halves or doubles the pupil area at every click, so one stop always means exactly one halving of light. The markings are rounded: f/5.6 is really 5.66 and f/11 is 11.3.

What circle of confusion should a machine vision calculation use?

Tie it to the pixel. Two pixels is the working default for edge measurement and code reading; four pixels is enough when you only detect presence or coarse features. On 3.45 µm pixels that is 6.9 µm versus 13.8 µm, and because depth of field scales directly with this number, the four-pixel budget buys twice the sharp range at the same aperture.

How do I gain depth of field without running into diffraction?

Move a different lever. Allow a bigger blur circle by using larger pixels or fewer pixels on the same field of view, reduce magnification with a wider field of view or a smaller sensor, or switch to a telecentric lens, which holds magnification constant through its stated depth of field. Raising the f-number alone eventually trades more resolution than the depth it buys.

Can the aperture be set from software?

On C-mount and F-mount machine vision lenses, no: the iris is a mechanical ring, usually with a locking screw, set at commissioning. Cameras with integrated optics differ — some 3D cameras expose an internal iris through their SDK, others fix it at the factory. When the iris is fixed, plan brightness entirely around exposure time, gain and lighting.

Do 3D cameras need aperture settings too?

Their 2D channel does. A 3D camera that also returns a texture image obeys the same f-stop arithmetic for brightness and depth of field, so set that channel with the same formulas. The depth channel itself is driven by projector or laser exposure, and models with a fixed aperture state their f-number with the optical data.