Stray Light in Machine Vision: Veiling Flare, Ghosting, Glare, and BBAR Coating Fixes
Why veiling flare, ghosting, and target-side glare are different problems with different fixes, and how BBAR coatings, lens design, and filters address each one.
Stray light is non-image-forming light that reaches the sensor after reflecting or scattering inside the lens, not a bright object in the scene. It raises the dark-region signal floor, which compresses contrast and can make low-luminance detail unresolvable. Veiling flare spreads this as broad haze; ghosting forms a localized secondary image; target-side glare is a separate, scene-side problem fixed with polarizers or lighting geometry. Fixing stray light means addressing the optical system directly: lens design, anti-reflection coatings, protective-window count, illumination geometry, or shielding.
What stray light means in machine vision
Stray light is any light reaching the sensor that did not follow the lens's intended image-forming path. Light entering the front element normally travels through a designed stack of optical surfaces to focus on the sensor. Stray light is everything else: light reflecting off the inner barrel wall, scattering off a polished element edge, bouncing between two element surfaces, or scattering from dust and edge defects near the aperture stop. None of it was part of the intended image geometry, but all of it can still land on the sensor.
The practical result is a background signal added on top of the real image signal. A dark region of the scene receives both its true low-luminance signal and the stray-light contribution, which raises the effective floor for shadow detail and compresses usable dynamic range. Depending on the source and the lens design, stray light shows up as:
- A spatially uniform haze across the frame (veiling flare)
- A structured secondary image displaced from a bright source (ghosting)
- Reduced MTF and apparent sharpness even when focus is correct
- Contrast loss that worsens as scene luminance increases
Why multi-element lenses accumulate stray light
Every air-glass interface reflects a fraction of incident light. An uncoated surface reflects approximately 4-5%; a well-coated surface reduces this to 0.1-0.5%, but not to zero. A lens with 10 optical surfaces has 10 opportunities for reflection, each adding to the stray-light budget. Some reflections exit back through the front and are lost; others find a path to the sensor. The design task is ensuring surface reflections land outside the sensor area, get absorbed by baffles, or scramble enough to sit in the noise floor rather than form a coherent artifact.
A protective window in front of the lens adds two more surfaces to this budget. If those surfaces are uncoated or poorly coated, the added stray-light contribution can be significant. That is one reason IP-rated M12 lenses that seal at the front element, eliminating a separate external window, offer a real contrast advantage in outdoor builds.
Stray light is an internal optical-system problem. The scene does not need a saturating highlight for it to matter. A moderately bright off-axis source, or ambient light scattered into the barrel, can raise the stray-light floor enough to affect high-dynamic-range applications.
Stray light versus glare, flare, and ghosting
These terms get used interchangeably outside engineering contexts. For machine vision work, the distinction matters because the correct fix depends on which problem is actually present.
| Problem type | Visual symptom | Usual cause | Likely fix |
|---|---|---|---|
| Stray light (general) | Reduced contrast, lifted shadow floor, haze or artifacts anywhere in frame | Non-image-forming light inside the optical path reaching the sensor | Lens design (baffles, AR/BBAR coatings), fewer windows, shielding |
| Veiling flare | Uniform haze across the frame, dark areas read grey rather than black | Diffuse scatter from multiple internal surfaces accumulating as a broad background signal | AR/BBAR-coated, low-scatter lens; fewer protective windows; lens hood |
| Ghosting flare | Structured secondary image (ring, disk, streak) displaced from a bright source | Reflection between two surfaces forming a secondary, usually defocused, image at or near the sensor plane | Low-ghost optical design; keep bright sources away from ghost-prone field angles |
| Target glare | Saturated specular highlight on the scene object, detail loss at the reflection point | Specular reflection from the scene target directly into the lens | Cross-polarization, lighting geometry, illumination angle change |
A camera showing contrast loss outdoors may be suffering from veiling flare, ghosting, or target glare, and the correct fix differs for each. A polarizer will not reduce ghosting from internal element reflections. A lens hood will not reduce a specular highlight from a shiny part in the scene. Identify whether the artifact is scene-dependent (glare), source-position-dependent and structured (ghosting), or a general contrast loss that worsens with overall brightness (veiling flare) before specifying a fix.
How do I reduce glare in machine vision?
Diagnose the failure mode before choosing a fix. For bright specular highlights on non-metallic surfaces, try cross-polarization: a linear polarizer on the illuminator and a crossed analyzer on the lens. For ambient light contamination, use a bandpass filter matched to the illumination wavelength. For sensor clipping in a high-dynamic-range scene, reduce exposure or add an ND filter. Moving the illumination or camera angle to shift the specular reflection off-axis is usually the fastest first test and costs nothing.
Glare is a scene-side problem, distinct from the internal stray light covered above. Specular reflection obeys the law of reflection: angle of incidence equals angle of reflection. On a polished surface the source image is preserved and redirected. If geometry puts that reflected image toward the lens, the camera sees the source, not the surface, and inspection algorithms trained on surface features fail in that region.
Cross-polarization for non-metallic surfaces
Cross-polarization uses two linear polarizers oriented 90 degrees apart: one over the illumination source, one (the analyzer) over the camera lens. Light striking a smooth non-metallic surface specularly retains its polarization orientation, so the crossed analyzer blocks it. Diffusely reflected light is scattered and depolarized during reflection, so a portion passes through. The result suppresses specular highlights while preserving diffuse surface detail.
This works well on smooth or glossy plastics, coated substrates, glass, ceramics, and printed circuit boards with solder-mask sheen. It works poorly on bare metals, which rotate and partially depolarize light during reflection, so a meaningful fraction of the metallic specular return still passes the analyzer. For bare metal, changing lighting geometry or using dark-field illumination is usually more effective. Each linear polarizer transmits roughly 50% of unpolarized light; two crossed polarizers block nearly all the specular return but pass only a fraction of the diffuse signal, depending on polarizer efficiency and how strongly the target depolarizes, so cross-polarization typically requires more illumination power, a longer exposure, or a wider aperture to compensate. A C-mount lens with an adjustable iris ring lets an engineer open the aperture to recover light after adding polarizers, then stop back down later if depth of field requires it. This is practical because illumination in most machine vision setups is programmatically controlled.
Bandpass and ND filters
A bandpass filter passes only a narrow spectral band matched to the illumination source and blocks out-of-band ambient light, which stabilizes contrast between day and night conditions. It does not suppress specular reflection from the controlled illuminator, because specular light at the target wavelength passes the filter just like diffuse light does. Neutral-density filters reduce total transmission uniformly and help when a scene has genuine dynamic range beyond the sensor's linear region, but they do not recover detail lost to specular geometry. They just lower the specular signal proportionally along with everything else. See bandpass filters in machine vision for filter selection by wavelength, and browse the filters collection for stocked options.
Capture a frame with the illuminator off to isolate ambient contamination. Move the light source 10-20 degrees to see if a highlight tracks it (specular geometry). Test cross-polarization on non-metallic parts. Reduce exposure to see if clipped highlights recover gradient. Each test isolates one variable before you commit to a filter or coating purchase.
Why HDR and outdoor scenes expose the problem
In a controlled indoor setup (a white LED ring at 45 degrees, a matte target, no windows), stray-light contributions from any individual reflective path are small in absolute terms. The brightest object in the scene may be 10-50x brighter than the darkest detail, and a stray-light floor of 0.1% of peak luminance is invisible in that context.
Outdoor scenes are fundamentally different. Direct sunlight is approximately 100,000 lux; a deep shadow in the same scene may be 10 lux. The luminance ratio is 10,000:1 or higher, and bright sources (sun, sky, headlamps, retroreflective signs) can appear anywhere in the scene, including at the frame edge or just outside the nominal field of view.
Off-axis sources outside the field of view
A lens does not stop admitting light at the edge of its specified field of view. Light from sources 20, 30, or 60 degrees outside the field of view still enters the barrel and can find an internal reflection path to the sensor. In a well-designed stray-light-optimized lens, these off-axis contributions are absorbed by baffles or exit the lens without reaching the sensor. In a lens not designed for this, they create veiling haze or ghost artifacts that appear to originate from nowhere in the scene, because the source that created them is not in the frame. This matters especially for automotive and outdoor embedded vision, where the camera is fixed and cannot avoid pointing toward bright sources at some orientations. See field of view in machine vision for how FoV is specified and measured.
HDR sensors need low-stray-light lenses to deliver their range
HDR image sensors extend usable dynamic range to 120 dB or more. A lens that limits effective contrast to 60 dB through stray light wastes the sensor's capability. For HDR to deliver its benefit (resolving bright highlights and dark shadow detail in the same frame), the optical system must maintain low stray light across the full luminance range of the scene. For an HDR sensor to operate near its rated dynamic range outdoors, a stray-light-optimized lens is close to a prerequisite.
Even a 1% stray-light contribution in a 10,000:1 scene collapses usable contrast in shadow regions. Specifying an HDR sensor for its wide dynamic range and then pairing it with a lens that limits realized dynamic range through stray light is an avoidable cause of unexplained contrast loss in outdoor camera designs.
What is a BBAR coating and how does it reduce stray light?
BBAR stands for broadband anti-reflective coating: a multilayer thin-film coating applied to a lens surface to reduce Fresnel reflection across a wavelength band rather than at a single design wavelength. Uncoated glass reflects approximately 4-5% of incident light per air-glass interface. A BBAR-coated surface typically reflects under 0.5% across the design band. Lower surface reflection means more light reaches the sensor and less bounces between elements to form flare or ghosts.
A single-layer quarter-wave AR coating minimizes reflection at one wavelength and rises steeply outside it, which is useful for narrow-band systems, such as an 850nm NIR illuminator, but poorly matched to combined visible/NIR imaging. A BBAR coating trades some peak performance for coverage across a wider band, commonly 400-700nm for visible-only designs or 400-900nm for combined visible/NIR use, which is more practical for systems using both visible and active NIR illumination or operating under variable lighting.
BBAR is applied during manufacturing of individual elements, not the assembled lens, and a datasheet notation like "BBAR on Lens 1 Surface 1" means exactly one surface in the optical stack carries it. The remaining surfaces may use standard AR coating, MgF2, or nothing at all. The total stray-light and ghosting budget depends on every surface combined, not just the one carrying the BBAR label. BBAR coating is also distinct from a hydrophobic coating: BBAR is an optical thin-film treatment that reduces Fresnel reflection, while a hydrophobic coating is a fluoropolymer surface treatment on the front element that repels water and oil and has no meaningful effect on reflection. A lens can specify both as separate features addressing separate problems.
| Coating type | What it reduces | What it does not solve |
|---|---|---|
| BBAR | Fresnel reflection across a wavelength band at the coated surface | Stray light from uncoated surfaces, barrel walls, or baffling gaps; distortion; aberrations |
| Narrow-band AR | Reflection at one target wavelength (e.g., 850nm) | Reflection at other wavelengths; combined visible/NIR use |
| Hydrophobic coating | Water, oil, and fingerprint adhesion on the front surface | Optical reflection, ghosting, flare, throughput loss |
Coating claims on any specific product should be verified against the current datasheet: the design band, which surfaces carry the coating, and average reflectance (Ravg) across that band all vary by product and are not guaranteed uniform across a lens family. Datasheets do not always publish this data; when they do not, treat coating claims as a partial input to lens selection rather than the deciding factor. For a lens with BBAR on only one or two surfaces, overall ghosting and flare performance still depends heavily on element count, baffling, and barrel design. See lens aberrations in machine vision for how geometry-driven effects interact with coating choices.
Wide-angle and fisheye designs are more exposed to this than telephoto lenses. A short-focal-length lens with a wide field of view increases the chance that bright sources enter from high off-axis angles and find a stray-light path through multiple elements, so reflection control at the exposed front surfaces matters more here than in a narrow-field telephoto design where entrance-pupil geometry limits off-axis coupling. Visible/NIR combined imaging has a related failure mode: if a coating covers only the visible band (typically 400-700nm) but the system also runs active NIR illumination, the uncoated NIR reflections can create ghost images that are invisible to the eye during bench setup but show up clearly in sensor output. Confirming the coating band matches every illumination source in the system, not just the primary one, avoids this class of field failure.
Confirm which surface carries the coating (one surface, not the whole stack). Check the stated wavelength range against your illumination source. Look for an average reflectance figure across the band rather than a single peak value. Confirm the BBAR spec is listed separately from any hydrophobic spec. Check for ghosting or stray-light test data alongside the coating claim before assuming coating alone determines flare performance.
How engineers reduce stray light in practice
The right approach depends on diagnosing which part of the optical system generates the stray light. There is no single universal fix; the paths below address different root causes.
Optical design: AR/BBAR coatings and low-ghost designs
The primary tool is anti-reflection coating on every optical surface. High-quality coatings reduce surface reflectance from roughly 4-5% uncoated to 0.1-0.5% per surface, and across a 10-surface lens that difference compounds. A stray-light-optimized lens also uses black-coated barrel baffles, matte-finished aperture stops, and design attention to which surfaces can form second-order reflection paths to the sensor.
Reducing the protective window count
Every additional optical surface, including a flat protective window, adds to the stray-light budget. In embedded builds requiring environmental protection, the better approach is an IP-rated lens that seals internally, eliminating a separate front window. A sealed M12 lens such as the CIL034 (IP67+) provides outdoor protection with no additional air-glass interfaces beyond the lens design itself. Removing a flat uncoated window eliminates two reflection surfaces that would otherwise add stray light and reduce transmission.
Lens hoods and mechanical shielding
A lens hood or housing extension blocks off-axis light sources before they enter the front element. It is one of the most effective and lowest-cost mitigations for fixed-mount cameras. The hood must be long enough and shaped to block sources at the angles where problems have been observed. In automotive applications where hood size is constrained by packaging, a stray-light-optimized lens design has to do more of the work.
Illumination geometry and spectral filtering
In setups with programmable illumination (LED ring lights, backlight arrays, structured lighting), arranging illumination to avoid bright sources in the direct lens view reduces stray-light loading. This does not help ambient or outdoor scenes, but in factory inspection it is often the simplest fix. For NIR active-illumination systems where ambient daylight is the stray-light source, a bandpass filter centered on the illumination wavelength rejects most of the broadband ambient contribution. Ambient energy inside the passband, such as sunlight at 850nm, still passes, and the filter will not fix stray light generated within the passband itself. See NIR imaging in machine vision and the filters collection.
What image processing cannot fix
Flat-field correction and image normalization can compensate for spatially uniform stray light (veiling flare) to a limited degree, if the stray-light pattern is stable enough to subtract a stored correction. This reduces available bit depth, does not handle scene-dependent stray light that shifts with source position, and cannot remove ghosting artifacts that move with the bright source. Image processing is a fallback, not a substitute for optical design.
Stray-light-optimized M12 lenses and glare-control accessories
These products address different parts of the stray-light and glare problem: HDR-rated automotive lens designs, sealed environmental protection without an extra window, and filters for ambient rejection.
From $99.00
CIL339: 3.9mm automotive HDR M12 lens
F/1.6 fixed, up to 12MP on 1/1.7" sensors. Stray-light optimized for the high dynamic range required in safety-critical automotive scenes; IP6K9K-rated, low-ghost, all-glass all-metal design.
View CIL339
From $39.00
CIL034: 3.2mm IP67+ low-distortion M12 lens
Fixed-aperture F/2.3, F/2.7, and F/4.2 variants, up to 10MP on sensors up to 1/1.8", 102° field of view. Seals at the front element, so no separate protective window is needed in the stray-light budget.
View CIL034
$249.00
CIL514: 25mm C-mount lens, 1.1" 12MP
F/2.8-16 adjustable iris ring, useful for recovering light lost to cross-polarization, then stopping back down for depth of field. Working distance 150mm-infinity.
View CIL514
$9.00
CBP850: 850nm bandpass filter
Single-notch interference filter for 850nm LED-illuminated systems that need ambient rejection to stabilize contrast. Unmounted, multiple sizes available.
View filters collectionStray-light and glare troubleshooting checklist
Work through these steps when an outdoor, HDR, or reflective-scene camera shows unexpected contrast loss, haze, ghost artifacts, or washed-out regions.
- Identify the artifact type. Is contrast loss spatially uniform (veiling flare), a discrete structured artifact displaced from a bright source (ghosting), or a saturated highlight tied to a specific scene surface (target glare)? Each maps to a different fix.
- Capture a frame with the illuminator off. If usable signal appears from ambient alone, ambient contamination is a factor. A bandpass filter matched to the illumination wavelength is the first countermeasure.
- Move the light source or camera angle 10-20 degrees. If a highlight moves with the source, the problem is specular geometry, not internal stray light. Adjust geometry to move the specular lobe off the lens axis.
- Count optical surfaces in the path. Lens elements, protective windows, filter glass, and sensor cover glass all add interfaces. Verify whether an uncoated window is adding two 4-5% reflection surfaces, and consider an IP-rated lens that seals internally instead.
- Test cross-polarization on non-metallic surfaces. If highlights drop significantly, expect to compensate with more illumination power or a wider aperture.
- Check whether reduced exposure recovers highlight detail. If gradients appear, it was clipping; if the region stays flat white, the geometry is the issue and exposure changes will not fix it.
- Confirm the lens is validated as stray-light-optimized or low-ghost if HDR or outdoor performance is required. Low-cost M12 lenses are often not specified or validated for stray-light performance, so confirm it on the datasheet rather than assume it.
- Test with a lens hood installed and removed to isolate how much of the artifact is off-axis entry versus internal scatter, and validate with real production parts and real line-side lighting before locking the configuration.
Frequently asked questions
What is stray light in a machine vision system?
Stray light is any light that reaches the sensor without having followed the intended imaging path through the lens. It originates from light scattering off internal barrel surfaces, reflecting off element edges, or bouncing between surfaces rather than passing cleanly through. It is not simply a bright object in the scene. It is unwanted light already inside the optical path, and its effect is a background signal that lowers contrast and can make features unresolvable at low luminance.
What is the difference between glare, flare, ghosting, and stray light?
Stray light is the general category: non-image-forming light inside the optical system reaching the sensor. Veiling flare distributes that light broadly as uniform haze, reducing contrast without obvious structure. Ghosting is a localized artifact, a structured secondary image from a specific surface-to-surface reflection. Glare is different: a saturating specular reflection from the scene target itself, a scene-side problem. Fixing target glare with polarizers or geometry does not fix internal stray light, and vice versa.
How do I reduce glare in machine vision?
Diagnose the failure mode first. For specular highlights on non-metallic surfaces, use cross-polarization: a linear polarizer on the illuminator and a crossed analyzer on the lens. For ambient contamination, use a bandpass filter matched to the illumination wavelength. For sensor clipping, reduce exposure or add an ND filter. Changing lighting geometry to move the specular angle off-axis is often the fastest first test.
What is a BBAR coating on a lens?
BBAR stands for broadband anti-reflective coating, a multilayer thin-film coating that reduces Fresnel reflection across a wavelength band rather than at a single design wavelength. Uncoated glass reflects roughly 4-5% of incident light per surface; a BBAR-coated surface typically reflects under 0.5% across the design band, improving throughput and reducing the internal reflections that cause flare and ghosting.
Why does stray light reduce contrast in machine vision?
Contrast is the ratio between the brightest and darkest regions a camera must distinguish. Stray light adds a spatially distributed background signal on top of the real scene signal, so a dark region receives both its true low-luminance signal and the stray-light contribution. That floor lifts the shadow level and compresses the range between bright and dark. In an HDR scene with a 10,000:1 luminance ratio, even a 1% stray-light contribution can make fine shadow detail unresolvable.
Why does stray light matter more in HDR and outdoor imaging?
HDR and outdoor scenes contain bright off-axis sources (sunlight, headlights, streetlights, bright sky) that can be orders of magnitude brighter than the detail the camera needs to resolve. Even sources outside the field of view can scatter enough light into the optical path to create veiling flare or ghosting. In a controlled indoor scene, stray light from any individual source is much lower in absolute terms, so a lens that passes indoor bench testing can fail once a bright sky or headlamp enters the scene.
Does a BBAR coating reduce ghosting and flare?
It reduces the contribution of the coated surface, but does not by itself guarantee a low-ghost lens. Ghosting also depends on element count and geometry, internal baffling, and barrel design. A lens with BBAR on a single surface can still show significant ghosting under strong backlighting if other surfaces or the housing contribute stray light. Evaluate the full optical system, not the coating spec alone.
Do polarizing filters reduce glare in machine vision?
Yes, for non-metallic specular surfaces. Cross-polarization places a linear polarizer on the illumination source and a crossed analyzer on the lens. Specular reflection retains the source's polarization and is blocked by the analyzer; diffuse reflection depolarizes and passes through, preserving surface detail. This does not work well on bare metals, which rotate and partially depolarize light during reflection.
Is a BBAR coating the same as a hydrophobic coating?
No. BBAR is an optical thin-film coating that minimizes Fresnel reflection at air-glass interfaces. A hydrophobic coating is a separate surface treatment, often a fluoropolymer layer on the front element, that repels water, oil, and fingerprints, with no meaningful effect on optical reflection. A lens can specify both as separate features addressing separate problems.
How can engineers reduce stray light in embedded vision systems?
Address the root cause rather than post-processing. Choose a lens with anti-reflection coatings on every surface and controlled baffling, or one explicitly validated as stray-light-optimized. Eliminate unnecessary protective windows with an IP-rated lens that seals at the front element. Use a lens hood to block off-axis bright sources. In controlled scenes, arrange illumination so bright sources are not directly visible to the lens axis. Image processing corrections have limited effect and cannot remove scene-dependent stray light or ghosting that varies with source position.
When does a protective window make stray light worse?
A protective window adds at least two new air-glass interfaces. Uncoated, each reflects roughly 4-5% of incident light; even AR-coated, a few tenths of a percent remain. In a multi-element system these reflections accumulate, and adding a standard flat window in front of an otherwise well-designed lens can increase veiling flare, particularly in high-dynamic-range scenes. An IP-rated lens that seals at the front element removes the need for a separate window and eliminates those interfaces from the stray-light budget entirely.
How should engineers evaluate a BBAR claim on a lens datasheet?
Confirm which surface carries the coating: "BBAR on Lens 1 Surface 1" means one surface in the full stack. Check the stated wavelength range against your illumination source. Look for an average reflectance figure across the band rather than a single peak-wavelength value. Confirm the BBAR spec is listed separately from any hydrophobic coating spec, and check whether the lens publishes ghosting or stray-light test data alongside the coating claim.
How should engineers test a camera for stray light problems?
Place a bright, well-defined light source at the field-of-view edge, then progressively at 30, 60, and 90 degrees off-axis. At each position, capture an image of a low-luminance target and compare shadow-region luminance to a baseline without the source present. Veiling flare shows up as a lifted dark-region histogram; ghosting shows up as a structured artifact displaced from the source position. Test with the source just outside the nominal field-of-view corner, which is often the worst case for ghost artifacts.
Need help selecting a low-stray-light lens for your application?
Commonlands engineering can help identify whether stray light, ghosting, or target glare is the root cause in your build, and select the right lens, coating, or filter for your sensor format, environment, and HDR requirements.