Depth of Field and Aperture

Depth of field is the range of distances over which the image stays acceptably sharp. It matters to a vision station because parts are never perfectly flat and never perfectly in place: a measurement taken on a surface that has drifted out of the sharp range is a measurement taken on a blurred edge, and blurred edges move. Aperture is the control you have over it, and it is not free — stopping down to buy depth of field costs light, and light is what lets you keep the exposure short.

Diagram showing a range of object heights within the sharp zone

Key takeaways

  • Depth of field is a range of acceptable sharpness, not a hard boundary.
  • Stopping down buys range and costs light, which you then pay back in exposure time or gain.
  • Smaller pixels and higher magnification both shrink the range you start with.
  • A tilt of the camera relative to the surface eats the range asymmetrically.
Isometric diagram of an industrial camera and an edge computing box connected by a single cable
The station-level hardware: one industrial camera plus one edge computing box

Depth of field is the distance range in front of and behind the plane of focus over which the image is sharp enough to use. It is not a yes-or-no boundary — sharpness falls off gradually — so the range depends on what "sharp enough" means for your measurement. A station measuring the position of a whole part can tolerate more blur than one measuring the width of a 0.1 mm gap, and both are described by the same lens at the same aperture. The number only becomes meaningful once the tolerance is fixed.

What sets the range

Four things decide how much range you get. The aperture is the one you control directly: a larger f-number means a smaller opening, which makes the cone of light arriving at each pixel narrower, which means a wider range of object distances still land inside it. Magnification is the second: the more the lens magnifies, the narrower the cone and the shallower the range. Pixel size is the third, and it is easy to overlook — the same lens on a sensor with smaller pixels resolves more detail and shows blur sooner, so the usable range shrinks. Working distance is the fourth: the same field of view from further away gives more range.

How the parameters trade against each other
ChangeEffect on depth of fieldWhat it costs you
Stop down (larger f-number)Wider rangeLess light: longer exposure or higher gain
Increase magnificationNarrower rangeMore detail per millimetre
Smaller pixelsNarrower usable rangeMore resolution per field of view
Move the camera further backWider rangeLarger field of view, less detail on the part
Tilt the camera to the surfaceRange becomes asymmetric or unusableOne edge of the view goes soft first

Stopping down is not free

The natural response to a part that will not stay sharp is to stop the lens down. That does widen the range, but every stop removes light, and the light has to come back from somewhere: a longer exposure, a brighter light source, or more gain. Longer exposure reintroduces the motion blur the station was designed to avoid. More gain lifts the noise floor, which eats the contrast the measurement depends on. A brighter source costs money, heat, and space on the fixture. So stopping down converts a sharpness problem into a light problem, and the light problem has to be solved too.

There is also a ceiling that catches people out: past a certain point, stopping down makes the image worse rather than better. Diffraction at a very small opening softens the whole image, not just the out-of-focus regions, so beyond roughly f/11 to f/16 on typical industrial lenses the picture gets softer everywhere. The exact point depends on the pixel size and the lens, but the direction is always the same. If the range is still not enough at that point, the answer is to change something else — a different lens, a different working distance, or a different measurement strategy — not to stop down further.

Estimating the range you actually need

The range you need comes from the process, not from the lens catalogue. Start with the flatness of the part, add the variation in how it sits in the fixture, add the fixture's own repeatability, and add whatever the conveyor or robot contributes. On a flat part held against a locating face, that total may be a few tenths of a millimetre. On a stamped part dropped onto a nest, it can be several millimetres. The number you get is the range the station has to cover, and it is a requirement to write down rather than a detail to discover later.

Two refinements are worth the effort. First, only the measurement features need to be sharp. If the station measures a bore on one face, the rest of the part can fall out of focus without consequence, and the range only has to cover the variation of that face. Second, sharpness requirements differ across a feature: locating the centre of a circular hole tolerates more blur than measuring its diameter to a tight tolerance, because the centre moves much less than the edge under blur. Spending the depth of field only where it is needed often makes an impossible requirement possible.

Common questions about depth of field

Can software correct for an out-of-focus image?

It can improve the appearance of an image, but it cannot recover information that was never captured. Deblurring sharpens edges visually while amplifying noise, and the result depends on how much blur there was — which is exactly what varies across the part. For measurement, a blurred edge is a displaced edge, and no amount of processing tells you reliably by how much. Fix the optics, or change what you measure.

Is a telecentric lens better for depth of field?

It is better for something else. A telecentric lens keeps magnification constant as the distance changes, so a part that moves towards or away from the camera does not appear to change size. That removes a measurement error the depth of field cannot address. It does not by itself give you a wider sharp range, and it usually costs working distance and money. The choice is about whether size changes with distance, not about focus.

How do I know the range in practice?

Measure it rather than calculate it. Put a step gauge or a set of shims of known heights into the field of view, image them, and see at which height the edge position starts to drift more than the tolerance allows. This takes an hour and gives a number you can trust, including the effect of your actual lighting and your actual measurement algorithm — neither of which any formula accounts for.


How much range do your parts need?

Tell us the part, the tolerance and how it is located. We will work out what the optics have to cover and where the trade should land.

Contact us

Related articles

View all

Need specific advice for your production line?

Our engineers can share practical approaches to process error prevention and SOP compliance inspection for your scenario.

Request a free trial plan