Machine Vision for Optical Inspection: Lighting, Optics and Camera Selection

Custom IZAK imaging-lens assembly with its interferometric test record and an alignment mount, at the IZAK booth, OASIS 2025

In short

  • Start from the smallest defect. In any optical inspection system, put at least 3 pixels across it for detection. For gauging, keep the pixel at about one tenth of the tolerance.
  • Lighting decides what the camera can see. Choose bright-field, dark-field, backlight or diffuse light by the defect and the surface, not by habit.
  • The lens sets three trade-offs. Magnification fixes the field of view; the f-number trades depth of field against diffraction blur; a telecentric lens removes the size error caused by height changes.
  • Motion needs short exposures. Keep blur under half a pixel: at 100 mm/s and 12 µm per pixel that is an exposure of 60 µs or less, so use a strobe and a global-shutter camera.

An optical inspection system is a chain of four parts: light, lens, camera and software. The chain is only as good as its weakest link, and in most failed projects the weak link was chosen first. Teams buy a camera, add a lens that happens to fit, and then try to rescue poor contrast in software. This guide works the other way round. It starts from the defect you must find, derives the pixel size on the part, chooses the lighting that makes the defect visible, and only then picks the lens and camera, with the formulas, a worked example and a calculator.

Start from the requirement, not the camera

Six numbers define a machine vision task. Write them down before you look at any datasheet:

  1. Smallest feature or defect that must be detected, or the tolerance of the dimension that must be measured.
  2. Field of view (FOV): the area that must be seen in one image, plus a margin for part position.
  3. Working distance and the space available for the lens and the lights.
  4. Part speed or cycle time, and whether the part stops under the camera.
  5. Height variation of the part and the fixture: it decides the depth of field and the size error.
  6. Surface: matte, shiny, transparent, coloured, textured. It decides the lighting.

Two rules of thumb then fix the pixel size on the object. For detection, put at least 3 pixels across the smallest defect (2 is the sampling minimum; 3 to 4 leaves margin for contrast and position). For measurement, aim for a pixel on the object of about one tenth of the tolerance. Sub-pixel edge algorithms can resolve a fraction of a pixel, but the 1:10 ratio keeps the vision system’s own variation small compared with the tolerance it checks.

Pixel on object = smallest defect ÷ pixels per defect  ·  Pixels needed = FOV ÷ pixel on object

A 48 × 36 mm field with 50 µm defects and 3 pixels per defect needs 16.7 µm per pixel, or 2880 × 2160 pixels. That one line already tells you the camera class.

Lighting: make the defect the highest-contrast thing in the image

Software can only find what the image shows. Good lighting turns a defect into a bright feature on a dark background, or the reverse, and makes the rest of the part uniform. The geometry matters more than the brightness.

TechniqueGeometryWhat it showsTypical use
BacklightLight behind the part, facing the cameraSharp silhouette; edges at maximum contrastGauging outlines, holes, pins; presence and position
Coaxial (on-axis) lightLight sent down the lens axis through a beamsplitterFlat mirror-like areas bright; scratches, pits and slopes darkPolished optics, wafers, fiber end faces, reflective labels
Directional bright-fieldRing or spot light at a high angle, reflection enters the lensGeneral surface detail and printMatte parts, colour and print checks
Dark-fieldLight at a low angle, specular reflection misses the lensFlat surface dark; scratches, chips, dust and edges brightChips on lens edges, scratches on glass, engraved marks
Diffuse domeLight from a hemisphere around the partSuppresses glare and texture on curved shiny partsCans, connectors, foil, solder joints
Structured lightProjected line or pattern, viewed at an angleHeight through triangulation3D profiles, warpage, glue bead height

Wavelength is a second lever. Short wavelengths (blue, 450–470 nm) give finer diffraction-limited detail and scatter more from small particles. Red and near-infrared light pass through many coloured plastics and reduce the effect of colour variation. Light of a colour complementary to a feature darkens it: a red LED looks dark under blue light. UV excitation makes adhesives and some contaminants fluoresce. A matching band-pass filter on the lens then rejects ambient light.

Polarizers on the light and the lens, crossed, remove specular glare from plastics and coatings. Strobing the light in sync with the camera trigger freezes motion and lets the LEDs run brighter than their continuous rating for short pulses.

Choosing the lens for an optical inspection system

Once the FOV and the camera sensor size are known, the lens follows from four relations. With sensor width w and height h, the optical magnification is set by the axis that fills first:

m = min(w ÷ FOVwidth, h ÷ FOVheight)  ·  Pixel on object = pixel ÷ m

For a lens focused at an object distance WD (measured from the lens principal plane), the thin-lens focal length is

f = WD · m ÷ (1 + m)

Real lenses have thick principal planes, so treat the result as the focal length to shop for, then set the final distance on the bench.

Depth of field. With working f-number N and an acceptable blur circle c on the sensor (one to two pixels is a common choice for inspection), the depth of field on the object side is

DOF ≈ 2 · N · c · (1 + m) ÷ m²

We checked this approximation against an exact thin-lens calculation: at m = 1, N = 8 and c = 10 µm both give 0.320 mm, and at m = 0.1, N = 5.6 and c = 6.9 µm they give 8.50 mm.

Diffraction. Closing the aperture increases the depth of field but enlarges the diffraction spot. The Airy disk diameter on the sensor is

dAiry = 2.44 · λ · N · (1 + m)

At 550 nm and f/8 near infinity that is 10.7 µm, three pixels of a 3.45 µm sensor. Small pixels therefore need fast lenses: once the Airy disk spans more than about two pixels, extra pixels add data but not detail. The lens must also resolve the pixel: a 3.45 µm pixel has a Nyquist frequency of 1 ÷ (2 × 3.45 µm) ≈ 145 line pairs per mm, and the lens needs useful contrast (MTF) there across the whole field.

Telecentric or not? In a conventional (entocentric) lens the magnification changes with distance. A height change Δz on a part at distance u changes a measured length L by about L · Δz ÷ u. For a 36 mm feature at 224 mm, a 0.5 mm height change gives an 80 µm error, almost seven pixels at 12 µm per pixel. An object-side telecentric lens keeps the magnification constant through its telecentric depth, which is why it is the default for gauging. Its front lens must be at least as large as the field of view, so it is most practical for fields up to roughly 100–150 mm; for larger fields, fix the height mechanically or calibrate per height.

Custom IZAK imaging-lens assembly with its interferometric test record and an alignment mount, at the IZAK booth, OASIS 2025
A custom imaging-lens assembly designed by IZAK, shown with the on-axis interferometric test record of the first production units. When an inspection task needs a field, distance or wavelength that catalogue lenses do not cover, the lens becomes part of the design.

Choosing the camera: pixels, shutter and speed

  • Resolution and pixel size. Choose the pixel count from the requirement above, with 10–20 % margin. Larger pixels collect more light per pixel and are more forgiving of lens resolution and diffraction; smaller pixels give more resolution in a smaller sensor but need a better, faster lens.
  • Global or rolling shutter. A global-shutter camera exposes all rows at once. A rolling shutter reads rows in sequence, so moving parts are skewed: if the rows are read over about 30 ms and the part moves at 100 mm/s, the bottom of the image is shifted 3 mm, 250 pixels at 12 µm per pixel. For moving parts and strobed light, use a global shutter.
  • Area-scan or line-scan. Continuous webs, rolls and cylinders are better imaged by a line-scan camera. The line rate must match the motion: line rate = speed ÷ pixel on object, so 100 mm/s at 12 µm needs about 8 300 lines per second, synchronised to an encoder.
  • Monochrome or colour. Monochrome gives the full resolution and the highest sensitivity. A colour camera with a mosaic filter samples red and blue on only a quarter of the pixels, so use it only when colour is the inspection criterion, as in LED colour checks.
  • Noise and dynamic range. Compare cameras by their measured quantum efficiency, temporal dark noise and saturation capacity, as reported under the EMVA 1288 standard, rather than by headline megapixels. A 10- or 12-bit output keeps subtle contrast that 8 bits may lose.
  • Trigger. A hardware trigger input and a strobe output make the timing repeatable on a production line.

Worked example: detecting chips on a lens barrel at 100 mm/s

A production line must find edge chips of 50 µm and larger on optical parts in a 48 × 36 mm field. Parts move at 100 mm/s, the lens can sit about 200 mm above the part, and the light is 525 nm.

  1. Pixels. 50 µm ÷ 3 = 16.7 µm per pixel, so the camera needs at least 2880 × 2160 pixels. A 4096 × 3000 sensor with 3.45 µm pixels (14.1 × 10.35 mm) is the next standard step.
  2. Magnification. Width gives 14.13 ÷ 48 = 0.294 and height gives 10.35 ÷ 36 = 0.2875. Height fills first, so m = 0.2875. The pixel on the object is 3.45 ÷ 0.2875 = 12.0 µm, which puts 4.2 pixels across a 50 µm chip; the real field is 49.2 × 36 mm.
  3. Focal length. f = 200 × 0.2875 ÷ 1.2875 = 44.7 mm. With a standard 50 mm lens the focus distance becomes 50 × (1 + 1 ÷ 0.2875) ≈ 224 mm.
  4. Aperture. At f/8, DOF = 1.72 mm, but the Airy disk is 13.2 µm, 3.8 pixels: the chips blur. At f/4, the Airy disk is 6.6 µm (1.9 pixels) and the DOF is 0.86 mm. Choose f/4 and hold the part height within ±0.4 mm with the fixture.
  5. Exposure. Blur under 0.5 pixel means 100 mm/s × t ≤ 6 µm, so t ≤ 60 µs. A 40 µs strobe gives 0.33 pixel of blur.
  6. Lighting. Chips on a polished bevel scatter light, so a low-angle dark-field ring makes them bright on a dark surface. A coaxial light is the alternative for scratches on flat polished faces.
Parameterf/8f/4 (chosen)
Pixel on object12.0 µm12.0 µm
Pixels across a 50 µm chip4.24.2
Depth of field (c = 2 pixels)1.72 mm0.86 mm
Airy disk on the sensor13.2 µm (3.8 px)6.6 µm (1.9 px)
Motion blur at 40 µs0.33 px0.33 px

The example shows why the lens and the mechanics are designed together: the sharpest aperture leaves less than a millimetre of depth, so the fixture becomes part of the optical budget.

Calculator

Machine vision optics calculator

Enter the field of view, defect size, sensor, distance and motion. The tool returns the magnification, pixel on object, pixels needed, focal length, depth of field, diffraction spot and motion blur, and flags the weak link.

Thin-lens model. Depth of field uses a blur circle of two pixels on the sensor and is valid while the depth is small compared with the working distance. The diffraction spot is the Airy disk diameter at the working f-number N·(1 + m). Motion blur assumes the part moves during the whole exposure. Use the results to choose components, then confirm on the bench.

Five mistakes that break inspection systems

  1. Choosing the camera first. The pixel on the object decides what can be found, not the megapixels.
  2. Fixing contrast in software. Thresholds tuned around poor lighting drift with every batch. Change the light geometry or wavelength instead.
  3. Closing the aperture for depth. Beyond a two-pixel Airy disk, fix the part height mechanically instead.
  4. Measuring with a conventional lens. Height variation becomes size error.
  5. Ignoring ambient light and timing. Use band-pass filters and a strobe synced to a hardware trigger.

Then validate the station like any measurement system, with known good and bad parts, repeated runs and false-accept and false-reject rates. Our guide to verification and validation of a laser medical device shows how to plan and document such tests.

How IZAK builds optical inspection systems

IZAK Scientific designs and builds inspection stations that combine optics, lighting, imaging and test software. Two examples are in our catalogue. The LED Color and Position Tester uses an imager with dedicated optics to check the colour, position and on/off state of every LED on a board, learns a reference board once and returns pass or fail for each LED to the production tester. The Fiber Ferrule Inspection System is a microscope-based imaging station that checks adhesive symmetry, end-face defects and cleanliness, fiber centre offset and transmission, and returns pass or fail per ferrule. For the criteria behind end-face inspection, see Fiber end-face inspection: zones and pass/fail criteria, and for a production LED example see LED and shape inspection for high-volume production.

When no catalogue system fits, we design one: from the requirement and the lighting study, through optical system design and custom lenses, to the software, the fixture and the acceptance test. See our electro-optical system design and development services.

IZAK products for this application

Ready-made inspection systems, and a design team for the ones that are not.

For a complete inspection station built to your specification, see custom electro-optical system design.

Planning an optical inspection system?Send the part, the smallest defect, the field of view and the line speed. An engineer will reply with a lighting, lens and camera concept.

Frequently asked questions

QHow many pixels do I need across a defect in machine vision?
At least 3 pixels across the smallest defect for reliable detection; 2 is the sampling minimum. For dimensional measurement, aim for a pixel on the object of about one tenth of the tolerance. A 48 × 36 mm field with 50 µm defects at 3 pixels each needs 2880 × 2160 pixels.
QWhen do I need a telecentric lens?
When you measure dimensions and the part height or position along the axis varies. With a conventional lens a height change Δz at distance u changes a length L by about L·Δz/u: 0.5 mm at 224 mm gives an 80 µm error on a 36 mm feature. A telecentric lens keeps the magnification constant through its telecentric depth.
QHow short must the exposure be for moving parts?
Keep the motion during the exposure under about half a pixel on the object: t ≤ 0.5 × pixel on object ÷ speed. At 100 mm/s and 12 µm per pixel that is 60 µs. Use a strobed light synchronised with a global-shutter camera.
>Tzachi Sabati Tzachi Sabati
CEO, IZAK Scientific
Physicist specializing in photonics and quantum technologies, with deep expertise in quantum sensors and advanced optical systems. Leads the Advanced Quantum Lab course at the Technion, bridging academic excellence with industry innovation. At IZAK Scientific, provides cutting-edge photonics-based solutions, developing customized inspection and sensing systems for R&D and production. Passionate about advancing quantum sensing applications and integrating novel technologies to meet industry needs.

 

Get new IZAK guides and tools by email

One short email a month: new technical articles, free calculators and product updates in laser measurement and electro-optics. No spam, unsubscribe anytime.

Get new IZAK guides and free calculators by email, one short email a month: Subscribe · Privacy Policy
Skip to content