Machine Vision Lighting: Matching the Light to the Surface and the Defect
Many inspection failures that look like software problems are lighting problems. How to choose lighting geometry, wavelength, and polarization by surface type, and how to test it on real parts.
Move the light
Same part. Same camera. Different light.
Side view
What the camera sees
- ScratchHidden
- DentFaint
- EdgeFaint
Brightfield: light from near the camera reflects off flat areas straight into the lens.
Choose a light or a surface to compare them.
In the working session we described in the first article of this series, the machine vision engineers spent more time on light than on cameras or models. Their rule was blunt: if a defect is not visible in the raw image, no algorithm will find it reliably. Most of what looks like a software problem on a struggling inspection station is a lighting problem.
Trade guidance has said the same for decades. Lighting is described as the most critical part of a machine vision application, poor lighting should not be expected to be fixed in software, and a lighting setup that works in the lab often does not carry over to the production floor [1]. That 1999 advice still holds.
This article is a practical guide to choosing lighting. It covers the main lighting geometries, wavelength and polarization, a surface-by-surface selection table, and a test procedure you can run on real parts. It is the third in our series on visual inspection. The first covers choosing rule-based, supervised, or unsupervised inspection by defect.
Start from the surface, not the light
Every lighting choice comes down to one question: where does light go after it hits the part, and does the camera receive it? Surfaces fall into a few families:
- Matte or diffuse surfaces (painted panels, paper labels, cast iron) scatter light in many directions. Almost any angle produces a usable image, and the job is even coverage.
- Specular or mirror-like surfaces (polished metal, glass, glossy plastic) reflect light at a single matching angle. The camera either sees a bright hotspot or nothing, depending on where the light sits.
- Textured surfaces (machined, brushed, or cast metal) mix both, and texture can look like a defect.
- Transparent parts (bottles, films, lenses) let most light pass through and show only edges and changes in thickness.
The goal is contrast: the defect should be clearly brighter or darker than the good surface around it. Pick the geometry that creates that difference for your surface and your defect.
The lighting geometries, and what each one reveals
Use the animated walkthrough at the top of this article to see each geometry on the same part, with a scratch, a dent, and an edge.
Brightfield (light from above, near the camera axis). Light reflects from flat areas straight back into the lens, so smooth surfaces look bright. On matte parts this gives even, readable images for labels, print, and presence checks. On shiny parts it creates glare, and fine scratches disappear into the reflection.
Darkfield (low-angle light). Light arrives at a shallow angle, so flat smooth areas reflect it away from the camera and look dark. Anything that breaks the surface, such as a scratch, an engraved character, a burr, or a raised mark, scatters light up into the lens and glows against the dark background [1]. Darkfield also makes the edges of transparent parts stand out [1]. It is the default starting point for surface scratches on smooth metal and glass.
Backlight (light behind the part). The part blocks the light and appears as a sharp silhouette. Backlight is the right choice for outlines, hole positions, gaps, and dimensional gauging, because edge position no longer depends on surface finish. It shows nothing about the top surface. Many clear parts are hard to see under a plain diffuse backlight [1], so transparent parts usually need darkfield or polarized backlight instead.
Diffuse dome (cloudy-day lighting). Light reaches the part from nearly every direction, so there is no single angle that produces a hotspot. Domes and similar hemispheric lights are used on uneven or faceted shiny surfaces [1], such as crimped terminals, foil packs, and ball bearings. The trade-off is that shallow surface texture, including some scratches, is softened along with the glare.
On-axis or coaxial light. A partial mirror sends light down along the camera's own viewing axis. Flat mirror-like areas reflect it straight back and look bright, while anything tilted, such as a dent edge, a scratch wall, or etched marking, reflects it away and looks dark. It is suited to flat polished parts and wafers, not curved ones.
Multi-angle lighting (photometric stereo). The camera stays fixed while the part is lit from several directions in turn. Because each pixel is seen under different light directions, the system can estimate the surface's slope at every point and separate shape from color [2]. That is why multi-angle lighting can show a shallow dent on a printed or discolored surface, and why it suppresses highlights on shiny metal [3]. Published research on stainless steel parts used 18 directional lights and found that estimation error rose sharply with fewer than 18 inputs; a defect detector trained on the resulting surface maps reached 75.5% mean average precision across stamp, scratch, and abrasion defects [3]. The authors positioned it for spot checks and offline testing, not full line speed, because the part must stay still through several exposures [3].
One station, more than one light
Many stations combine geometries. A backlight measures the outline, then a darkfield ring checks the top surface for scratches, triggered in sequence on the same part. If one light cannot show every defect on your list, plan two exposures rather than one compromise image.
Wavelength and polarization
Color contrast. A colored defect shows up best under light of the complementary color. A monochrome camera with a light and filter matched to that color usually gives a cleaner image than a color camera, because every pixel sees the wavelength you care about rather than splitting the sensor among red, green, and blue filters. Color filtering cannot separate two things that are the same color, so check whether the defect truly differs in color from the good surface.
Near-infrared. Silicon camera sensors respond to light somewhat beyond the visible range, into the near-infrared. Some materials and inks look very different in near-infrared, which can help with dark plastics or printed backgrounds. The effect varies by material, so the only reliable test is imaging your own parts.
Ultraviolet. UV light is mainly used to make a material fluoresce, so an adhesive bead, coating, or contamination that contains a fluorescing agent glows in an otherwise dark image. Fluorescence can be weak, and the light's wavelength has to match what the material responds to.
Polarization. Light reflected from shiny or wet surfaces is partly polarized, which is why polarizing filters cut glare [5]. In inspection, one polarizing filter goes on the light and a second on the lens, rotated 90 degrees to the first, so the mirror-like reflection is blocked while diffuse light from the part passes [1]. Because reflected light is only partly polarized, expect glare to drop sharply rather than vanish in every case [5]. Polarizers also absorb light, so plan for a brighter source or longer exposure.
Choosing lighting by surface type
The table below is a starting point, not a substitute for testing. It reflects general practice and the principles above.
| Surface or part | Common defect question | First lighting to try | Watch out for |
|---|---|---|---|
| Flat mirror-like (polished metal, wafer) | Scratches, pits, etched marks | Coaxial on-axis light | Any tilt sends light away from the lens |
| Curved or faceted shiny (terminals, foil, bearings) | Presence, shape, gross damage | Diffuse dome | Fine texture and shallow scratches soften |
| Smooth metal or glass | Scratches, engraving, burrs | Low-angle darkfield | Dust and fingerprints glow too |
| Matte (labels, painted panels) | Print, color, presence | Angled overhead brightfield | Uneven coverage across a wide field |
| Machined or cast texture | Dents, dings, shallow damage | Multi-angle lighting | Part must be still; more cycle time |
| Outline, holes, gaps | Dimensions and position | Backlight | Shows nothing about the top surface |
| Transparent (bottles, film) | Edge cracks, chips, inclusions | Darkfield or polarized backlight | Plain backlight can make clear parts vanish |
| Wet, oily, or glossy coated | Anything glare hides | Crossed polarizers plus diffuse light | Less light reaches the camera |
Test lighting on real parts, in the real place
Lighting decisions should come from images of your parts, not from catalog photos. A short test procedure:
1. Collect a test kit. Gather good parts that show normal variation (different lots, finishes, and colors) and real defective parts for every defect on your list, including borderline ones. 2. Image each part under each candidate geometry. Keep the camera, lens, and distance fixed so lighting is the only variable. 3. Judge contrast by eye first. If an engineer cannot see the defect clearly in the raw image, the setup is wrong. Do not move on to tuning software. 4. Check that good-part variation stays quiet. A geometry that makes scratches glow but also lights up tool marks will cause false rejects. 5. Repeat at the line. Ambient light, part position, and line speed change results, which is why lab lighting often fails on the floor [1]. Add a shroud if ambient light reaches the part. 6. Write the lighting into the station record. Record the geometry, angle, distance, wavelength, filters, and exposure, so the setup can be reproduced after maintenance.
Lighting is maintained equipment
A lighting setup that worked at commissioning will not stay the same. LED sources lose output gradually; the U.S. Department of Energy describes LED useful life as the operating hours until the source emits 70% of its initial light output, and notes that all light sources change color over time [4]. An inspection recipe with fixed thresholds can start failing well before an LED reaches that point. Lens windows also collect dust, oil mist, and residue, which lower contrast in the same way.
Treat lighting and optics like any other maintained asset. Image a reference target or golden part each shift, trend its brightness and sharpness, and schedule cleaning and light replacement before the trend crosses a limit. Monitory can track those readings alongside the station's asset record, so a fading light becomes a planned work order rather than a sudden jump in false rejects. For a second look at what your camera sees today, request the free lighting review at the end of this article. The final article in this series covers station drift and maintenance in depth.
Summary
Lighting decides what the camera can see, and the right geometry depends on how the surface reflects light. Use darkfield for scratches and raised marks on smooth parts, backlight for outlines and gauging, a dome for curved shiny parts, coaxial light for flat mirror-like parts, and multi-angle lighting when dents must be separated from color and gloss. Add wavelength and polarization to raise contrast or remove glare.
Next steps for one station:
1. Classify each part surface as matte, specular, textured, or transparent. 2. Pick one or two candidate geometries per defect from the table. 3. Build a test kit of good parts with normal variation and real defects. 4. Image the kit under each candidate with the camera fixed, and judge contrast by eye. 5. Record the final setup and add reference-target checks to the station's maintenance plan.
For the method that reads those images, see choosing rule-based, supervised, or unsupervised inspection. For the full workflow from detection to disposition, read computer vision quality inspection: from defect detection to corrective action.
Frequently asked questions
Why can't the AI model just learn around bad lighting?
A model can only learn from what is in the image. If glare hides a scratch or low contrast blends a dent into texture, the information is missing, and no amount of training restores it. Fix the lighting first, then train.
Which lighting should we try first for scratches?
On smooth metal, glass, or plastic, start with low-angle darkfield light, which makes scratches bright against a dark surface [1]. On flat mirror-like parts, also try coaxial light. On textured surfaces where tool marks look like scratches, consider multi-angle lighting.
When is multi-angle lighting worth the extra cycle time?
When the defect is a change in shape, such as a dent or ding, on a surface whose color or gloss varies. Multi-angle lighting separates slope from color [2], but published systems need the part to stay still for several exposures [3], so it fits stop-and-inspect stations and sampling better than continuous high-speed lines.
How do we deal with glare on shiny or wet parts?
Try a diffuse dome first. If glare remains, add crossed polarizers on the light and the lens [1][5], and allow for the light they absorb by raising source brightness or exposure.
How often should inspection lighting be checked?
Image a reference target or golden part every shift and trend brightness and sharpness. LED output declines gradually [4], so a trend shows when cleaning or replacement is due long before false rejects rise.
References
[1] Vision Systems Design, "How to select lighting and optics for vision systems", 1999. https://www.vision-systems.com/factory/robotics/article/16736570/how-to-select-lighting-and-optics-for-vision-systems
[2] R. J. Woodham, "Photometric Method for Determining Shape from Shading", University of British Columbia Department of Computer Science Technical Report 84-10, 1984. https://www.cs.ubc.ca/sites/default/files/tr/1984/TR-84-10.pdf
[3] Y. Cao et al., "Photometric-Stereo-Based Defect Detection System for Metal Parts", Sensors, 2022. https://pmc.ncbi.nlm.nih.gov/articles/PMC9655976/
[4] U.S. Department of Energy, "LED Basics". https://www.energy.gov/eere/ssl/led-basics
[5] OpenStax, "University Physics Volume 3, 1.7 Polarization". https://openstax.org/books/university-physics-volume-3/pages/1-7-polarization
Free for manufacturing and maintenance teams
Free lighting review
Send us what your camera sees today and we will suggest lighting to test on your parts.
You send
- Current images of good and defective parts
- A photo of the station and a note on the part surface
You get back
- Lighting geometries to try first for each defect
- A short test plan you can run with your own parts
Not sure where camera inspection fits yet? A discovery call walks through your lines and assets to find the inspection and monitoring problems worth solving first. Prefer someone on site? See the free half-day on-site assessment.
Related articles
Ready to put this into practice?
See how Monitory helps manufacturing teams implement these strategies.