Stain Defect Visual Inspection
Stain defect visual inspection: for oil stains, water marks, fingerprints and process dirt on leather, fabric and foam surfaces, diffuse uniform illumination with grayscale/color difference comparison distinguishes natural texture from real stains, outputs OK/NG and marks positions.
defect Overview
Surface stains and dirt are revealed by grayscale and color contrast; the difficulty lies in distinguishing them from the material's natural texture
A stain is oil, water, dust or processing dirt adhering to the material surface, producing a gray-level or chromaticity difference from the surrounding substrate under uniform diffuse light. As long as the contrast between the stain and the background reaches a level the camera can resolve, machine vision can detect it consistently; the key risk is misjudging the material's own pattern, color mottling or print marks as stains, so the judgement must be based on a registered normal-appearance datum.
Stain-type defects appear in the image as a local region whose gray level or chroma differs from the surrounding substrate, usually with irregular edges and uneven density inside. They can be oil stains, water stains, adhesive stains, fingerprints, or dust deposits, and may also come from stamping lubricant, handling gloves, or ambient dust. Because stains themselves have no fixed shape, rule-based algorithms cannot exhaustively cover them with a single template; the more practical approach is difference comparison under stable illumination and white balance.
The primary difficulty of stain inspection is not "whether you can see it" but "whether it counts as a defect". Genuine leather, PU synthetic leather and knitted fabrics have natural texture, color mottling and even prints of their own, and these are all normal appearance; treating them as stains leads to an extremely high over-rejection rate. In engineering practice, OK samples are usually used first to establish a background datum (or the average of the same batch), and then local areas that deviate from the datum are tested for significance.
Another category of difficulty comes from reflective and transparent stains. An oil stain may only appear slightly brighter along the specular direction, and a water stain is nearly invisible once dry; such low-contrast stains place higher demands on light source angle, camera dynamic range and calibration consistency. For critical parts, we recommend further dividing stains into "wipeable" and "absorbed / irreversible", with the quality department defining the reject threshold for each.
Occurrence Causes
Only when the cause is known can you decide which station should check for it
- Carried in during processing: stamping/cutting lubricant, mold release agent residue, glue overflow
- Handling and assembly: glove oil stains, fingerprints, dust deposits, and shedding from packaging materials
- Ambient dust: airborne dust from open stations on the production line and insufficient filtration in the air supply system
- The material itself: uneven coloring of natural leather pores is misread as stains (normal appearance)
- Incomplete cleaning: water marks from the previous process step, or cleaning agent residue not dried before the part enters the line
imaging Key Points
Whether it can be detected depends first on whether it can be captured
Uniform Diffused Light
Provides stable, non-directional illumination so stains appear as gray-level / color differences rather than shadows; best suited to oil and water stains
Coaxial Light
Suppresses surface highlights and reduces interference from reflection spots in stain judgement; suitable for coated or slightly reflective surfaces
Multispectral / Color Imaging
Adding near-infrared or specific wavelength bands beyond RGB improves the color difference contrast between certain oily stains and the substrate
White Balance Reference
Light sources and cameras must be calibrated regularly so that color temperature drift does not misjudge normal color variation as a color-difference stain
judgement Method
The judgement centers on "the significance of the local difference from the registered normal appearance". The image is first positioned and background-registered, then the area, maximum deviation, average deviation, and connectivity shape of suspicious regions are measured on the difference map; only deviations that exceed both the area and the intensity dimensions become defect candidates.
No fixed number is given for the threshold: the cost of an escape (letting a stain through) and of over-rejection (treating normal texture as a stain) is usually asymmetric, so the threshold should be biased toward the safer side; the specific upper and lower limits must be quantitatively defined by the customer's quality department together with the release criteria, and saved as a recipe at changeover. Clearly different "soaked-in" stains and slight "wipeable" stains should be handled in separate grades.
| Judgement Dimension | Description |
|---|---|
| Area | Minimum/maximum area threshold for the difference region; below it the region is treated as noise, above it the part is rejected outright |
| Intensity | The maximum deviation in grayscale or chromaticity relative to the background, distinguishing slight color variation from real stains |
| Shape | Whether the edge transitions naturally: hard edges are usually external stains, while gradual transitions are usually natural texture |
| Position | Whether it falls on a functional surface or an appearance surface; appearance surfaces and hidden assembly surfaces can be rejected at different grades |
| Recoverability | The quality department defines a graded disposition strategy for wipeable and penetrated marks |
Applicable algorithm
Background Registration and Difference Map
Build a reference from OK samples or the same-batch mean, then compare pixel by pixel to obtain a difference image
- Register positioning first to avoid false differences caused by position drift
- Smooth the difference image to suppress noise
Blob and saliency analysis
Apply threshold segmentation and connected-component statistics to the difference image to extract area, intensity and shape
- Dual-threshold filtering by area and intensity
- Low-contrast stains require a higher camera dynamic range
Deep learning classification
Run binary classification on suspicious regions to distinguish real stains from natural grain/marks
- Collect real stain samples and normal pattern samples
- Sample coverage determines the false-rejection ceiling
Common Materials
Common Industry
Common Question
What types of stains can visual inspection detect?
Why are color blooms on genuine leather often misjudged as stains?
How do you balance escapes and over-rejection in stain inspection?
Can oil stains be captured clearly on reflective surfaces?
Should Wipeable Stains and Penetrating Stains Be Judged Separately?
What is the smallest stain that can be detected?
Does switching to a differently colored material require readjustment?
Submit sample testing
The key to stain inspection is to "distinguish external dirt from the material's natural appearance"; below are examples comparing typical material surfaces with the reference.
Submitted successfully
We have received your sample testing request. A solution engineer will contact you within 1 business day via contact you.
Need to assess imaging conditions, defect criteria and cycle time item by item? Go to the Full Requirement Assessment →
Send Us Your Defect Samples and We Will Measure Them and Show You the Results
Whether a defect can be detected depends on whether imaging captures the defect features. Provide OK and NG samples and we will run actual imaging and judgement tests on the equipment.