This project targets industrial cover-glass inspection. The goal is to automatically recognize and localize scratches, abrasions, dust, stains, clamping defects, and insufficient polishing in high-resolution glass images. The main challenges are large image size, small local defects, low contrast, fragmented faint scratches, and black edge regions that can interfere with model inference.
Instead of applying a single full-image detector, the project decomposes the problem into patch-level classification and local contour localization, then maps the local predictions back to the original image coordinate system.
PyQt-assisted annotation: the full glass image is shown on the right, while local patches are enlarged for precise annotation.
2. Data and Task
The dataset contains seven types of regions: abrasion, scratch, clamping defect, insufficient polishing, dust, stain, and normal glass. Because normal samples dominate the dataset, class-balanced sampling is used during dataset construction.
ObjectsSurface scratches, abrasions, dust, stains, clamping defects, and insufficient polishing.
InputHigh-resolution glass images converted into patch-level classification and segmentation samples.
OutputDefect category, local mask or contour, and labelme-style polygon annotations in source-image coordinates.
Metrics97.92% recall, 1.37% false positive rate, 3.17% miss rate, and 96.76% inference accuracy.
3. Pipeline
The system combines deep-learning classification, image-processing segmentation, and geometric contour refinement. ResNet selects suspicious patches, while BM3D, threshold segmentation, and Hough line detection localize the defect contour.
Split the high-resolution source image into overlapped patches.
Apply edge resampling and mirrored mask completion for boundary patches.
Classify each patch with ResNet to select suspicious regions.
Run BM3D denoising and gray-level thresholding on defect patches.
Use Hough line detection to connect fragmented scratch segments and export labelme annotations.
The classification module uses ResNet on preprocessed patches. Training applies rotation, flipping, scaling, cropping, histogram equalization, and Gamma correction to improve robustness to scratch direction, location, brightness, and contrast variation.
Confusion matrix for evaluating multi-class defect recognition and false alarms on normal samples.
5. Segmentation and Contour Localization
For suspicious patches, the system performs grayscale conversion, denoising, threshold segmentation, and contour extraction. BM3D is used because it suppresses random noise while preserving thin edge structures better than Gaussian filtering in faint-scratch scenarios.
BM3D denoising and threshold-based scratch mask extraction.
Hough line detection is introduced to connect fragmented scratch segments. It is especially useful when threshold segmentation only captures partial responses of a faint scratch.
Hough line detection improves continuity for fragmented faint scratches.
6. Remapping and Visualization
The integrated module stores each patch's source-image offset, class result, segmentation mask, and contour points. Local coordinates are shifted back to the original image coordinate system and exported as labelme-readable polygon annotations.
Full-image labelme visualization and a local faint-scratch detection example.
7. Summary
The value of this project lies in decomposing high-resolution, low-contrast industrial inspection into controllable submodules. ResNet provides robust candidate screening; BM3D and thresholding extract local defect structures; Hough line detection improves contour continuity; PyQt annotation and labelme export close the data and verification loop.
Engineering takeaway: a single deep detector is not always the most practical option for industrial defect inspection. For thin, faint, imaging-sensitive scratches, combining learning-based classification with interpretable image processing can be more effective for validation and deployment.