Lenses & opticsExplainer

Depth of field simulation: when sharp previews mislead

Check what a depth of field simulation actually models, estimate blur from aperture and magnification, and validate usable object depth with images.

LumaSpec Vision9 min read Share on LinkedIn

On this page 10 sections
  1. 01What a sharp preview actually proves
  2. 02Check which optical controls affect the output
  3. 03Estimate depth of field from an explicit blur allowance
  4. 04Worked example: a depth range that depends on the criterion
  5. 05Why stopping down eventually stops helping
  6. 06Choose hardware around the missing information
  7. 07Validate usable depth with physical images
  8. 08When the usual depth-of-field estimate is wrong
  9. 09Checks before committing to a setup
  10. 10Questions

A sharp preview can confirm framing while saying nothing about focus tolerance. This matters when you are selecting a lens for parts with raised features, variable presentation height, or several inspection planes. A geometric scene renderer may place every surface sharply, even when the corresponding physical setup would produce substantial defocus. You need to establish what the software models before using its images to choose hardware. Start by separating coverage from sharpness, estimate the acceptable object-depth range, and then verify that range with captured images.

What a sharp preview actually proves

A depth of field simulation is useful only when its optical assumptions match the decision you need to make. Field-of-view calculations primarily answer which area reaches the sensor. Depth-of-field calculations ask how far an object can move from the focused plane before blur becomes unacceptable.

Those are different questions. A renderer can calculate perspective and image scale without calculating how an out-of-focus point spreads across neighboring pixels.

Preview behavior What it can support What remains unproven
Object size changes with distance Framing and perspective planning Defocus at the new distance
Aperture changes brightness Exposure-related behavior Aperture-dependent sharpness
Focus distance changes edge blur Some defocus modeling Agreement with the physical lens
Blur increases away from a focused plane Qualitative depth sensitivity Inspection-specific usable depth
Distortion or dark corners appear Those particular modeled effects Accurate depth of field

A visually attractive image is not an acceptance test. Even a physically based renderer needs an appropriate lens model, aperture, focus setting, and image sampling method.

For dimensional work, the separate limits described in telecentric depth-of-field validation also matter: an edge can look recognizable while its measured position is no longer acceptable.

Check which optical controls affect the output

Use a controlled test scene rather than judging a complex assembly. Include a slanted surface or several high-contrast targets at different distances. Keep lighting, display scaling, and image processing unchanged throughout the comparison.

  1. Find the model description. Look for explicit treatment of aperture, focus distance, defocus, sensor sampling, and lens aberrations. Missing documentation means uncertainty, not evidence of a particular default aperture.
  2. Change aperture while holding focus fixed. Compare, for example, f/2.8 and f/8 if the model permits them. Choose target depths where the predicted defocus difference should be visible.
  3. Change focus distance without moving the scene. A model that handles defocus should move the region of highest sharpness through the scene.
  4. Move a target while leaving focus unchanged. Inspect edge profiles at native image resolution, not just the preview window.
  5. Separate optical changes from display changes. Resizing, sharpening, and automatic contrast can disguise differences in the generated image.

Some tools automatically refocus when an object moves. Others may treat a focus-distance control as a framing input. Check the documented meaning of each control before interpreting its behavior.

Estimate depth of field from an explicit blur allowance

Depth of field is not a sharply bounded region where every detail is perfectly focused. It is the range accepted under a chosen sharpness criterion. A practical starting point is an allowable blur-circle diameter at the sensor.

For a thin-lens approximation with unity pupil magnification, small defocus, and approximately symmetric near and far limits:

c = b × p DOF ≈ 2 × N × c × (1 + m) / m² c = acceptable sensor-plane blur-circle diameter b = allowed blur diameter in pixels p = sensor pixel pitch N = marked lens f-number m = image size / object size DOF = approximate total object-space depth range

Use the same length unit for pixel pitch, blur diameter, and the resulting depth range. Magnification and f-number are dimensionless.

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.

This approximation explains several useful trends. Increasing the f-number increases geometric depth of field. Increasing magnification reduces it strongly. Accepting a larger blur circle also increases the calculated range, but sacrifices fine detail.

The formula is a planning estimate, not a universal lens specification. It becomes less suitable when near and far limits are strongly asymmetric or the actual lens differs substantially from the assumed pupil geometry.

Use the object-space sampling calculation to connect pixel pitch and magnification to the feature you need to inspect. A blur allowance that suits presence detection may be unsuitable for locating an edge precisely.

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

Worked example: a depth range that depends on the criterion

Consider a hypothetical sensor with a 3.5 µm pixel pitch, operating at 0.10× magnification and f/4. These are example inputs, not specifications assigned to a catalog product.

First choose a sensor-plane blur allowance of 2 pixels:

p = 3.5 µm = 0.0035 mm c = 2 × 0.0035 mm = 0.0070 mm DOF ≈ 2 × 4 × 0.0070 × (1 + 0.10) / 0.10² DOF ≈ 0.0616 / 0.01 DOF ≈ 6.2 mm total

Under the symmetric approximation, that suggests roughly 3.1 mm on either side of the focused plane. It does not establish a guaranteed tolerance for an inspection algorithm.

Now tighten the allowance to 1 pixel. The permitted blur diameter halves, so the estimated total depth becomes approximately 3.1 mm. Nothing changed mechanically; only the acceptance criterion changed.

The sampling scale provides another useful check:

Object-space sampling = p / m Object-space sampling = 3.5 µm / 0.10 = 35 µm per pixel A 0.21 mm feature spans approximately: 0.21 mm / 0.035 mm per pixel = 6 pixels

A 2-pixel blur diameter is significant relative to a feature spanning only 6 pixels. The feature may remain visible while its width, contrast, or measured position becomes unreliable.

For a sampling decision rather than an optical tolerance estimate, use camera resolution for dimensional inspection. Pixel coverage and focus tolerance must both support the measurement.

Why stopping down eventually stops helping

Changing the example from f/4 to f/8 doubles its estimated geometric depth of field to about 12.3 mm. That does not mean every inspected feature becomes sharper throughout that range.

A smaller aperture increases diffraction blur and reduces the light reaching the sensor. Depending on illumination and motion, the exposure adjustment may introduce another source of lost detail.

For a diffraction-limited circular aperture, the approximate Airy-disk diameter to the first dark ring is:

d_Airy ≈ 2.44 × wavelength × N_effective N_effective ≈ N × (1 + m)

The effective-f-number expression again assumes unity pupil magnification. Using a wavelength of 0.55 µm and the example magnification gives:

  • At f/4: effective f-number ≈ 4.4, so Airy diameter ≈ 5.9 µm.
  • At f/8: effective f-number ≈ 8.8, so Airy diameter ≈ 11.8 µm.

These are diffraction estimates, not predictions of the complete image. The Airy diameter and a geometric blur-circle allowance describe different blur distributions. Do not simply add them or treat them as interchangeable acceptance limits.

Actual performance also depends on aberrations, wavelength, contrast, sampling, and processing. The discussion of small pixels and usable detail explains why more pixels alone cannot restore contrast lost optically.

Choose hardware around the missing information

Start with machine vision lenses and use the lens finder to narrow focal length, sensor coverage, and mount. Then check the information a preview cannot supply: working-distance range, aperture provision, optical performance, and focus stability.

The LS-FFL-0567 lists a 16 mm focal length and F2.8-22 aperture range. It is a candidate to investigate when aperture selection is part of the planning exercise, not proof that a particular depth range will pass inspection.

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

For area scan cameras, use the camera finder to identify candidates, then obtain the sensor dimensions and pixel pitch needed for your calculation.

The LS-CMR-0166 provides 4000 × 3000 resolution over USB3. Confirm its pixel pitch and mechanical compatibility before combining it with a lens or applying the example calculation.

Area scan cameras12 MP USB3 area scan camera, IMX226, 1/1.7" rolling shutter, 30 fps, 4000 × 3000 resolution (LS-CMR-0166)LS-CMR-0166
Sensor format
1/1.7"
Interface
USB3
Resolution
12 MP
Shutter
Rolling
$560.00View partBuild a system with it

Do not substitute a sensor's nominal format designation for its measured active width or pixel pitch. The calculation needs physical dimensions, and the lens must cover the active sensor area you intend to use.

Use calibration-target coverage margins when planning framing. Leaving room for presentation variation is separate from allowing enough depth for focus variation.

Validate usable depth with physical images

Build a depth sweep around the intended focus plane. Use representative surface finishes and real inspection features, rather than a target that is easier to image than production parts.

For a predicted total range near 6 mm, an initial sweep might cover 10 mm in 1 mm increments. Follow with smaller increments around the first failing positions. These are test-planning values, not required settings for a particular product.

Keep aperture, exposure, gain, illumination, processing, and focus fixed during each sweep. Record the actual target displacement and retain the original images.

Evaluate three things at every position:

  • Image contrast: does the relevant feature remain distinguishable from its surroundings?
  • Measurement behavior: does edge position, reported width, or another measured value remain within the application tolerance?
  • Decision behavior: do representative acceptable and defective parts still receive the correct classification?

A sharpness score can help organize the sweep, but it is not a substitute for inspection performance. Use a consistent region of interest and the guidance on selecting a reliable focus metric.

Repeat the sweep after the equipment reaches its normal operating condition. If the best-focus plane shifts during operation, investigate temperature-related focus drift rather than treating it as ordinary part-height variation.

When the usual depth-of-field estimate is wrong

A tilted or deep object does not have one representative distance. Measure the closest and farthest critical surfaces. A background surface may be irrelevant, while a small raised inspection feature determines the required range.

Telecentricity does not remove focus limits. Reduced perspective variation and sufficient sharpness are separate requirements. Use the actual lens data and measurement validation rather than assuming constant image scale means constant image quality.

Motion blur is not defocus. If an image becomes softer only during movement, changing aperture may not address the cause. Separate stationary and moving captures before changing the optical design.

Digital sharpening does not recover missing evidence. It may improve apparent edge contrast while changing edge location or amplifying noise. Validate using the production processing settings.

Multiple inspection planes may require another arrangement. Repositioning the camera, reducing magnification, changing the view, or using separate acquisitions can be more effective than stopping down further. Focus stacking requires suitable scene stability and should not be assumed to work on moving parts.

Checks before committing to a setup

Use this short checklist to turn the simulation into a documented planning tool:

  • Record whether the preview models defocus or only framing.
  • Record aperture and focus assumptions; leave neither as an unexplained default.
  • Establish minimum feature size, required contrast, and measurement tolerance.
  • Calculate magnification and object-space sampling from physical dimensions.
  • State the blur allowance used in the depth estimate.
  • Include part-height variation, tilt, and focus-position uncertainty in the required range.
  • Check diffraction and exposure before selecting a smaller aperture.
  • Validate the full depth range with representative physical images.
  • Confirm mount, coverage, working distance, and access to adjustment controls before ordering.

Once these inputs are defined, start the lens configuration workflow. If a lens model or simulation leaves an assumption unresolved, send the required field of view, object-depth range, and acceptance criterion through application support before committing to hardware.

Questions

Does a sharp simulated image prove the object will be in focus?

Not necessarily. A preview may calculate framing and perspective without modeling defocus. Check its documentation and test whether changing aperture, focus distance, and target depth changes edge blur. Until that behavior is established, use the preview for coverage planning rather than as evidence of focus tolerance.

Which inputs are needed for a depth-of-field estimate?

Start with magnification, lens f-number, and an acceptable sensor-plane blur diameter. Pixel pitch helps express that allowance in pixels. The estimate also needs stated optical assumptions; actual lens pupil geometry, aberrations, diffraction, and the inspection criterion can change the usable range.

Should the acceptable blur diameter be one pixel or two?

There is no universal choice. A larger blur allowance may be adequate for coarse presence detection but unsuitable for precise edge measurement. Relate the allowance to feature size and sampling, then test representative acceptable and defective parts throughout the required depth range.

Why not use the smallest aperture available?

Stopping down increases geometric depth of field, but also increases diffraction and reduces available light. Longer exposure can introduce motion blur. Compare inspection performance across aperture settings rather than choosing the smallest opening solely because a geometric calculation predicts more depth.

How can a simulation be checked against a physical setup?

Compare representative captures across a measured depth sweep using the same aperture, focus, exposure, and processing settings assumed in the model. Judge feature contrast and inspection accuracy, not just visual similarity. Agreement at the focused plane alone does not validate the predicted depth range.