Two production lines can inspect the same product, yet one catches scratches reliably with a few simple tools while the other keeps rejecting good parts no matter how long the thresholds are tuned. The difference is rarely how "smart" the software is. It comes down to the nature of the defects and of the surface being inspected. This article helps quality engineers, production engineers and plant owners answer a practical question about surface defect inspection with machine vision: when are traditional, rule-based algorithms enough, and when does deep learning justify the investment?
For a general comparison of the two approaches, see our article deep learning vs traditional machine vision. This piece takes a different route: it starts from the type of surface defect you actually face.
What are surface defects, and why are they hard to inspect?
Surface defects include scratches, stains, dents, porosity, burrs, discoloration, rust and coating flaws. They are hard because they have no fixed shape: a scratch can be long or short, faint or deep, and appear anywhere. A good surface is not uniform either: machined metal has tool marks, molded plastic has texture, and fabric and leather have natural patterns.
The real task is to tell the normal variation of good parts from the abnormal variation of defective ones. The two families of methods handle this very differently.
Traditional algorithms: fast and transparent, but the defect must stand out in the image
Traditional (rule-based) tools are rules that an engineer sets up: thresholding, blob analysis (measuring the area and perimeter of bright or dark regions), edge detection, pattern matching, golden-image comparison and color measurement. They often run well on a smart camera without a GPU-equipped PC.
Strengths
- Easy to explain: you know exactly why a part was rejected (blob area above limit, contrast below limit).
- Low data needs: a few dozen sample images are often enough for initial setup and validation, depending on the application.
- Compact hardware, short processing time, easy PLC integration.
Limits
- Heavily dependent on lighting: if the defect does not stand out in the image, no rule will save it.
- Prone to false rejects when the background has texture, patterns or reflectivity that changes between batches.
- With many irregular defect types, the number of rules grows fast and becomes hard to maintain.
Deep learning: learning from images instead of writing rules
Deep learning learns features from labeled images (or only from good images, in anomaly-detection mode). On textured surfaces and variable defects, a trained model usually separates defects from background better than hand-written rules. Manufacturers such as Cognex offer dedicated deep learning tools for machine vision, and a new generation of AI cameras is bringing this capability closer to the edge.
Strengths
- Handles complex surface texture and variable defects.
- Reduces manual re-tuning when products or material lots change slightly.
- Can classify defect types (scratch, stain, dent), which helps root-cause analysis.
Limits
- Needs representative data, especially for rare defects; inconsistent labeling degrades the model.
- Often needs a PC or device with a GPU, plus a training phase and model maintenance.
- Harder to explain: engineers must verify that the model looks at the defect and not at background texture.
Quick selection table by defect and surface type
| Situation | Usually suitable approach | Reason |
|---|
| Smooth, uniform surface; high-contrast defects (missing holes, dark stains, large chips) | Traditional | Blob analysis and thresholds are enough; fast and explainable |
| Presence/absence, position, dimension checks | Traditional | Fixed geometry, clear rules |
| Machined, molded, leather, fabric or wood texture | Deep learning (or hybrid) | Variable background makes fixed thresholds produce false rejects |
| Defects with many shapes: fine scratches, faint marks, light porosity | Deep learning | Hard to describe with rules |
| Very few defect images, plenty of good ones | Deep learning anomaly mode, or traditional if defects are clear | No need for many defect images to train |
| Clear rejection reasons required for customers or audits | Traditional, or hybrid | Decisions are easy to trace |
In practice, many strong systems use both: traditional tools locate the part and crop the region of interest, then deep learning evaluates the surface inside that region.
Lighting decides before the algorithm does
Whichever approach you choose, the image must show the defect. Shallow scratches often appear only under low-angle or dark-field light; dents on glossy surfaces need coaxial or diffuse lighting; highly reflective surfaces glare under the wrong light. An AI model cannot catch a defect the camera has not captured. Test lighting and optics before thinking about training. See BeeVision's machine vision lighting guide.
An 8-question checklist before you decide
- Does the defect stand out clearly in the image under your current lighting?
- Is the good surface uniform, or does it have natural texture and patterns?
- Do defects have a repeatable shape, or does each one differ?
- How many real good and defective images do you have, and do they include rare defect types?
- Who will label them, and are the defect criteria (size, acceptable level) agreed in writing?
- Which costs more to your plant: missed defects or false rejects?
- How much processing time does your cycle time (takt time) allow per part?
- Does the plant have someone to maintain the model when materials, lots or ambient light change?
If questions 1, 2 and 3 are answered "yes, uniform, repeatable", traditional algorithms are usually a sensible starting point. If the surface is textured and defects are diverse, consider deep learning from the start to avoid weeks of rule tuning.
Common mistakes
- Using AI to compensate for poor lighting. The model learns noise and becomes unstable between shifts.
- Collecting only "clean" defect images. Samples must include borderline defects and normal variation between lots.
- No agreed NG standard. Two people labeling the same mark differently confuses the model.
- Ignoring the cost of false rejects. A system that "catches everything" but scraps too many good parts still causes losses.
- No maintenance plan. When a material or coating supplier changes, you need a way to re-verify and retrain.
Illustrative application examples
Picture a metal component plant: stamped parts with smooth surfaces, where the main defects are missing holes and large burrs. A smart camera with traditional tools is sufficient, quick to set up and easy to explain to the quality team. By contrast, for molded plastic parts with surface texture, where the main defects are fine scratches and light stains, threshold rules often produce false rejects because of the texture; deep learning anomaly detection combined with traditional part location is a better fit. These are generic illustrations, not figures from a specific project; real results depend on the sample, lighting and quality standard of each plant.
How BeeVision helps
As a Cognex partner in Vietnam, BeeVision engineers advise on both approaches and have no default answer: your real data decides. The usual process is that you send OK/NG samples, engineers test lighting and optics, run traditional tools first, compare with deep learning when needed, and then recommend a camera, lighting and software setup. For more, see our visual inspection solution page and the article Cognex vs Keyence: which machine vision brand to choose.
What to prepare for a proof of concept (POC)
- OK samples, NG samples and borderline samples, with the defect type noted.
- Accept/reject criteria (defect size, location); a written document is best.
- Line speed, product size, ambient light and vibration at the installation point.
- Integration needs: reject signal, image storage, PLC connection.
Frequently asked questions
Does deep learning fully replace traditional algorithms?
No. For geometry, measurement and code reading, traditional tools remain fast and reliable. Deep learning is strong on complex surfaces and variable defects, and the two are often combined.
How many images are needed for training?
There is no universal number; it depends on defect type, surface variability and training mode. The most reliable way is to test on your real samples.
Is a GPU required?
It depends on the tool and level of detail. Some modes run without a GPU, others need a PC with a compatible GPU. Check the requirements from the manufacturer for the version you use.
Which matters more, lighting or the algorithm?
Lighting comes first. If the defect is not clearly visible in the image, neither approach will be stable.
Follow BeeVision on LinkedIn and YouTube for more machine vision knowledge, and send your product samples through the send samples for POC page so our engineers can test them for free.