Imaging

Machine Vision Optics for Inspection

An inspection system is a measurement instrument. Before you choose a camera, decide what you need to detect and how it differs from the background. This article works through the optical chain from defect to pixel: resolution, contrast, depth of field, telecentricity, lighting, and motion, then ends with how to prove the system works.

Start from the defect

Write down four things before you pick hardware:

  1. The smallest defect that matters, as a size and a type: a scratch, chip, particle, bubble, stain, or dimensional error.
  2. The contrast mechanism. Does the defect absorb, scatter, refract, change color, or change height? This decides the lighting more than anything else.
  3. Throughput: part size, line speed, and the time available per part.
  4. The cost of each error type. An escape (a missed defect) and a false call (a good part rejected or sent to manual review) usually have very different costs, and the system's threshold will trade one for the other.

Everything that follows is about getting enough pixels and enough contrast on that defect, in focus, without blur, every time.

The resolution chain: pixels, optics, and contrast

Sampling. The size of one pixel projected onto the object is \(p_\text{obj} = \text{FOV}/N_\text{pixels}\). A 150 mm field imaged onto 4096 pixels gives 36.6 µm per pixel. The finest pattern the sensor can sample is set by the Nyquist frequency, \(\nu_N = 1/(2p)\) on the sensor: 145 line pairs/mm for 3.45 µm pixels.

Optics. A lens cannot pass arbitrarily fine detail. Even a perfect, diffraction-limited lens has a modulation transfer function (MTF) that falls to zero at the cutoff frequency

\[ \nu_c = \frac{1}{\lambda N_w}, \qquad N_w = N\,(1 + |m|), \]

where N is the f-number set on the lens and \(N_w\) is the working f-number at magnification m. The Airy-disk diameter, \(2.44\,\lambda N_w\), is the smallest blur spot the lens can form.

0.00.20.40.60.81.0050100150200250300Image-plane spatial frequency (line pairs/mm)MTF (contrast)Nyquist, 3.45 µm pixels (145 lp/mm)f/2.8: 69 % contrast at Nyquistf/5.6: 40 % contrast at Nyquistf/8: 19 % contrast at Nyquist
Diffraction-limited MTF at 550 nm and magnification 0.1. At f/8 the lens passes only about 19 % contrast at the Nyquist frequency of a 3.45 µm-pixel sensor, so the sensor resolves finer detail than the optics deliver. Real lenses fall below these curves because of aberrations, especially at wide apertures.

Contrast is the currency. Resolution charts measure whether a pattern can be resolved, but inspection succeeds or fails on whether the defect's signal stands clear of noise: sensor noise, surface texture, and part-to-part variation. A defect that changes intensity by 5 gray levels on a background that varies by 10 is not reliably detectable at any resolution. In practice, size the system so the lens MTF at the defect's spatial frequency is comfortably above 30–40 %, and engineer the lighting so the defect signal is several times the background noise.

Choosing magnification, field of view, and working distance

The magnification is fixed by the sensor size and the field of view: \(m = \text{sensor width}/\text{FOV}\). With the thin-lens approximation and working distance WD measured from the lens to the object,

\[ f \approx \frac{\text{WD}\cdot m}{1+m} \qquad\Longleftrightarrow\qquad \text{WD} \approx f\,\frac{1+m}{m} . \]

Example. A 12 MP sensor of 4096 × 3000 pixels at 3.45 µm measures 14.1 × 10.4 mm. Covering a 150 mm field needs m = 0.094. At a 500 mm working distance that calls for f ≈ 43 mm; with a stock 50 mm lens, the working distance becomes about 580 mm. Then check three things:

  • The lens's image circle covers the sensor diagonal (17.5 mm here).
  • The lens is rated for the pixel size. Many lenses designed for older 5 µm-pixel sensors cannot deliver contrast at 145 lp/mm.
  • Distortion at the field edge is acceptable for any measurement you intend to make, or you have a calibration plan.

The machine vision lens calculator runs these numbers, including depth of field and object-space pixel size.

Depth of field and the f-number trade-off

Depth of field is how far the object can move along the optical axis before the blur in the image exceeds an acceptable size c, usually one or two pixels. For magnifications well below 1,

\[ \text{DOF} \approx \frac{2\,N\,c\,(1+m)}{m^2}. \]

With c = 2 pixels (6.9 µm) and m = 0.1, the depth of field is about 6 mm at f/4, 8.5 mm at f/5.6, and 12 mm at f/8. Stopping down buys depth, but it costs two things:

  • Light: exposure scales as \(1/N^2\), so each full stop halves the light. That pushes you toward longer exposures (motion blur) or brighter, more expensive lighting.
  • Diffraction: the Airy diameter at f/8 and m = 0.1 is 11.8 µm, about 3.4 pixels. That is already larger than the 2-pixel blur budget, so the sharpest focus no longer looks sharp.

A practical optimum is where diffraction blur roughly equals the allowed blur, \(2.44\,\lambda N_w \approx c\). For this example that gives N ≈ 4.7, so f/4–f/5.6 is the sweet spot. If the parts need more depth than that, change the geometry (lower magnification with a higher-resolution sensor, or tighter part presentation) rather than stopping down further.

Telecentric lenses

With a conventional (entocentric) lens, magnification changes with object distance: \(\Delta m/m \approx -\Delta z/\text{WD}\). At a 300 mm working distance, a ±1 mm height variation changes the magnification by ±0.33 %, which is ±0.33 mm across a 100 mm part. That error is fatal for gauging.

An object-space telecentric lens places its aperture stop at the back focal point so that chief rays are parallel to the axis in object space. Magnification is then constant through the depth of field. Telecentricity is specified as a residual angle. At 0.1°, a 1 mm height change shifts an edge by only about 1.7 µm. Telecentric lenses also look straight into bores and along vertical walls without perspective. Paired with a collimated backlight, they give razor-sharp silhouettes for edge measurement.

The cost is size: the front element must be at least as large as the field of view. Telecentric lenses suit fields up to roughly 100–200 mm. Larger parts need multiple cameras, line-scan imaging, or calibrated conventional lenses with tight height control.

Lighting for glass and other specular parts

Lighting decides contrast, and contrast decides detection. For transparent and mirror-like parts such as glass, polished metal, and coated films, the lighting geometry matters more than anything else in the system.

Coaxial bright fieldSpecular light returns to lens;defect scatters it away → darkLow-angle dark fieldLow-angle light reflects away;scratches/particles scatter in → brightBacklight (transmission)Edges, bubbles, inclusionsblock or deflect light → dark
Three basic geometries. Coaxial bright field shows defects dark on a bright background; low-angle dark field shows scattering defects bright on dark; backlighting reveals edges and anything that blocks or deflects transmitted light.
  • Bright field (coaxial or on-axis). Light reflects specularly from a flat surface straight back into the lens, and scratches, pits, and stains scatter it away and appear dark. This works best for flat, reflective surfaces. On glass, each uncoated surface reflects about 4 % (\(R = ((n-1)/(n+1))^2\) for n = 1.5), so the rear surface makes a second, offset ghost image that the algorithm must handle.
  • Dark field (low-angle ring or line light). Specular reflection misses the lens entirely, and only light scattered by scratches, particles, chips, and edges reaches the camera. The background is dark and defects are bright. Dark field can detect features much smaller than a pixel, because a sub-pixel scratch still scatters enough light to brighten a pixel. It cannot measure their size.
  • Backlight (transmission). For silhouettes, edges, and chips, and for bubbles, stones, and inclusions inside transparent material. A collimated backlight with a telecentric lens gives the most accurate edges.
  • Polarization. A polarizer on the light and an analyzer on the lens suppress glare. Crossed polarizers on transparent parts reveal stress birefringence (photoelasticity), which shows residual stress in glass.
  • Structured light and deflectometry. Reflecting a known pattern off a specular surface turns small slope errors (waviness, distortion, dents) into large, measurable pattern distortions.
  • Wavelength. For features much smaller than the wavelength, scattering rises steeply at shorter wavelengths, so blue or UV light can improve sensitivity to fine particles and haze. Monochromatic light plus a matching bandpass filter also rejects ambient light.

On continuous sheets, line-scan cameras with line lights are standard. Several lighting channels, such as bright field and dark field, can be captured at once with separate cameras, or by alternating strobes on successive lines.

Sizing the smallest detectable defect

Rules of thumb that hold up in practice:

  • Detection: at least 3 pixels across the defect when contrast is good. Two pixels is marginal and sensitive to where the defect falls on the pixel grid.
  • Classification (telling a scratch from a particle from a bubble): 5–10 or more pixels across.
  • Measurement: the measurement resolution should be about one tenth of the tolerance. Sub-pixel edge methods can repeat to roughly 0.1–0.2 pixel with good lighting and calibration, but verify that with a gauge study rather than assuming it.

Example: 100 µm chips on a 150 mm field with 36.6 µm pixels are only 2.7 pixels across. That is marginal. Halve the field per camera, move to an 8k line-scan sensor, or use dark field, where the chip's scattered light makes it far more detectable than its pixel count suggests.

Motion blur, exposure, and strobing

A part moving at speed v blurs across

\[ \text{blur (pixels)} = \frac{v\,t_\text{exp}}{p_\text{obj}} \]

during an exposure \(t_\text{exp}\). For a conveyor at 0.5 m/s with 36.6 µm object pixels and a blur budget of half a pixel, the exposure must be 37 µs or shorter. That is well within reach of strobed LED lighting, which supplies short, intense pulses so the lens can stay at its optimum aperture. Line-scan cameras avoid the problem differently: the line rate is synchronized to motion, here \(v/p_\text{obj} \approx 13.7\) kHz for square pixels. Driving the line trigger from an encoder on the conveyor keeps the pixels square when line speed varies. The motion blur calculator covers both cases.

Validating an inspection system

An inspection system is a gauge, and it needs the same scrutiny as any other gauge.

  • Build a defect library. Collect real and seeded defects spanning the size range around the specification limit, for every defect type and on the full range of good-part appearance: color, coating, and texture variation.
  • Measure probability of detection (POD) versus size. Plot POD as a function of defect size rather than quoting one number. A classical demonstration of 90 % POD with 95 % confidence at a given size is 29 detections in 29 trials, because 0.9²⁹ ≈ 0.047 < 0.05.
  • Quantify false calls on a large set of good parts. A 0.5 % false-call rate at 2,000 parts per day means 10 manual reviews every day, and reviewers who learn to ignore the system.
  • Run attribute agreement analysis (AIAG MSA) for pass/fail decisions against expert judgment. Run a standard gauge R&R for any dimensional measurement the system reports.
  • Verify continuously. Check golden and limit samples at the start of each shift, monitor light intensity, check focus, and archive images of rejects for traceability and retraining.

Escapes and false calls trade against each other through the decision threshold. Choose the operating point deliberately, using the costs you wrote down at the start, and re-check it whenever lighting, optics, or the product changes. Inspection data also belongs on control charts. A rising false-call rate is often the first sign of a dirty lens, an aging light, or an upstream process drift. See SPC and process capability.

References

  1. E. Hecht, Optics, 5th ed., Pearson (2017).
  2. W. J. Smith, Modern Optical Engineering, 4th ed., McGraw-Hill (2008).
  3. U.S. Department of Defense, MIL-HDBK-1823A, Nondestructive Evaluation System Reliability Assessment (2009).
  4. AIAG, Measurement Systems Analysis (MSA), 4th ed. (2010).