Industrial Defect Detection — Classical Computer Vision
About Project
An automated visual quality-control pipeline that classifies and localizes five types of surface defects (normal, scratch, stain, missing_part, deformation) on 256x256 product images, using classical computer vision instead of deep learning.
The pipeline combines Top-Hat and Black-Hat morphological filtering with Canny edge detection to segment the candidate defect region, extracts 10 hand-crafted features (area, aspect ratio, solidity, brightness, distance from center, and more), and classifies with a 200-tree Random Forest. Bounding boxes are corrected with a per-class shrink factor learned from the training set, since raw segmentation tends to overestimate defect size at blurry transition pixels.
With only 75 training images (15 per class) on a synthetic dataset with consistent visual signatures, deep learning would have overfit badly. The classical CV + Random Forest approach reached a macro F1 of 0.96 on validation and 0.97 on the hidden test set, with a combined final score of 0.90/0.91 — all without a GPU and with training times measured in seconds.
An earlier iteration tested class-specific detectors (Hough line transform for scratches, LAB color-deviation for stains, convex-hull differencing for edge defects) against a single generic Top-Hat/Black-Hat + Canny detector. The generic method won across every class and was simpler to maintain, so it was adopted uniformly for all defect types.


