Shenzhen Kai Mo Rui Electronic Technology Co. LTDShenzhen Kai Mo Rui Electronic Technology Co. LTD

News

Summary of Algorithms for Defect Inspection in Machine Vision

Source:Shenzhen Kai Mo Rui Electronic Technology Co. LTD2026-07-31

Defect inspection is one of the most critical applications in the industrial machine vision industry. Almost all industrial products undergo defect detection procedures before being launched onto the market, with the core goal of ensuring product qualification.
Two mainstream inspection modes are adopted for product defect detection: manual visual inspection and industrial machine vision inspection. When implementing defect inspection via machine vision technologies, the commonly adopted technical approaches are summarized as follows:

I. Traditional Image Processing Algorithms

There are two primary technical routes for defect inspection based on traditional image algorithms:

1. Feature Engineering

Feature engineering is the most prevalent method for defect detection. It leverages conventional image processing algorithms to analyze visual characteristics including grayscale values, variance, mean brightness, color, shape, contour, area and other parameters to identify defects. This approach features high flexibility and rapid development cycles. In practical deployment, relevant parameters for defect features are generally exposed on the software interface to allow flexible adjustment by operators.

2. Template Matching

Template matching works by predefining standard image templates, then comparing these templates with captured test images to spot defects. Its applicable scenarios are relatively limited.For example, for label defect inspection on beverage bottles of a specific brand: partial defect types can be identified via feature engineering, while template matching is adopted simultaneously. Pre-set qualified label templates are matched against sampled images to judge whether labels have flaws or anomalies.

II. Computer Vision (CV) Algorithms

Computer Vision (CV) algorithms, a subset of Artificial Intelligence (AI) algorithms, enable computers to understand and interpret visual images. Since machine vision systems process image data exclusively, AI algorithms referred to in this field mostly correspond to CV algorithms. Practitioners in the industry usually use the term "AI algorithms" rather than "CV algorithms" for general communication.
CV algorithm categories cover image classification, object detection, semantic segmentation, instance segmentation, object tracking, OCR, face recognition, image generation, anomaly detection and more. Among them, image classification, object detection and instance segmentation are the three most widely deployed algorithms for industrial defect inspection:

1. Image Classification

As the name suggests, image classification algorithms categorize images and assign corresponding class labels. It is further divided into single-label classification and multi-label classification based on task requirements. Popular backbone networks include ResNet, MobileNet, EfficientNet, etc.
Theoretically, image classification can directly process full-frame captured images to output defect categories. However, industrial camera frames contain massive irrelevant background areas apart from the target inspection region. Such redundant background information interferes with model training and drastically reduces classification accuracy. For this reason, end-to-end full-image classification is rarely adopted in actual industrial projects.

640.webp.png

2. Object Detection

Object detection algorithms locate all target objects of interest within an image via bounding boxes, outputting both object coordinates and category information.
The workflow is straightforward: annotate large-scale defect datasets to train a dedicated defect detection model.The YOLO series stands out as the most classic object detection algorithm, boasting balanced high accuracy and fast inference speed. During practical use, input images must be resized to fit the dimension requirements of the detection model.When original images feature ultra-high resolution with tiny pinpoint defects occupying an extremely small pixel proportion, defects may be lost during the scaling preprocessing step. To avoid this issue, high-resolution raw images are split into multiple cropped patches for separate detection; final inspection results are aggregated afterwards.
A major limitation of object detection lies in dataset dependency. As a supervised learning algorithm, its performance heavily relies on sufficient annotated data. Insufficient datasets lead to poor detection precision. In real projects, continuous data collection and iterative model tuning are required to achieve satisfactory inspection performance.

 640.webp (1).png

3. Instance Segmentation

Instance segmentation is an advanced evolution of object detection. Instead of coarse bounding boxes, it generates precise pixel-level masks to delineate target regions.
Advantages in defect inspection:
  1. Enables far more accurate defect localization compared with bounding box-based object detection;
  2. Effectively distinguishes overlapping, adjacent or nested defects that cannot be well separated by object detection algorithms.
For ultra-large resolution images, the same image cropping strategy as object detection is applied.Like object detection, instance segmentation belongs to supervised learning and demands large annotated datasets. Its pixel-wise mask annotation is far more time-consuming than bounding box labeling. Similarly, ongoing data accumulation and repeated model iteration are indispensable for stable industrial deployment.

III. Hybrid Scheme: Traditional Image Algorithms + CV Algorithms

Combining conventional image processing with AI CV algorithms is another mainstream industrial solution.
The typical pipeline:
Traditional image algorithms first roughly locate potential defective regions; the cropped Region of Interest (ROI) defect images are then fed into AI classification networks for precise defect categorization.
This hybrid architecture perfectly addresses the pain point of traditional algorithms: strong defect localization capability yet weak classification performance.



Related News

Professional Engineer

24-hour online serviceSubmit requirements and quickly customize solutions for you

+8613798538021