Skip to content

Arnavjain0805/Surface-Defect-Detection-System

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

🔎Surface-Defect-Detection-System🔍

Project Overview

This project implements an automated Surface Defect Detection System designed to inspect surface images (e.g., metals, fabrics, plastics) for anomalies such as scratches, cracks, or uneven textures. It utilizes a Gabor Filter Bank model to perform robust texture analysis and feature extraction, distinguishing between normal surface patterns and defects.

Tech Stack

  • Language: Python 3.x

  • Core Libraries:

    • OpenCV (cv2): Image loading and pre-processing.

    • scikit-image (skimage): Specifically, gabor_kernel for generating the model's filter bank.

    • NumPy: Matrix operations and numerical computing.

    • Matplotlib: Visualization of input images, filter responses, and detection results.

Detection Model: Gabor Filter Bank

Instead of a "black box" neural network, this system uses an interpretable Texture Analysis Model based on Gabor Filters. This approach is highly effective for surface inspection because it mimics the human visual system's perception of texture and edges.

  • Model Architecture:
  1. Filter Bank Generation:

    • The model constructs a "dictionary" or bank of filters by varying parameters such as orientation (theta), frequency (sigma), and wavelength (lambda).

    • This allows the system to be sensitive to defects appearing at different angles and scales.

  2. Feature Extraction (Convolution):

    • The input image is convolved with every filter in the bank.

    • Normal Texture: Produces a uniform, low-energy response.

    • Defect: Causes a high-energy response or "spike" in specific filters, acting as a signal for anomaly detection.

  3. Energy Segmentation:

    • The system aggregates the filter responses to create an "Energy Map." Thresholding techniques are then applied to this map to segment the defect from the background.

Project Structure

Files Description
SDDS.ipynb Jupyter Notebook containing the Gabor Filter model and detection logic
IMG1.png Sample input image for testing
README.md Documentation

Key Features

  • Automated Feature Extraction: No manual feature engineering required; the Gabor bank automatically extracts relevant texture descriptors.

  • Robustness: Effective against invariant changes in illumination and contrast.

  • Visualization: Detailed outputs showing the original image alongside the segmented defect heatmap.

Installation & Setup

  1. Clone the Repository:

    git clone https://github.com/your-username/surface-defect-detection.git
    cd surface-defect-detection
    
  2. Install Dependencies:

    pip install opencv-python numpy matplotlib scikit-image
    
  3. Run the System Open the Jupyter Notebook to process images:

    jupyter notebook IVP_Final.ipynb
    

Tuning & Troubleshooting

Handling Blurry or Highly Zoomed-In Images

Surface images, particularly those with high magnification or fabrics such as damaged cloth, may contain significant noise (fuzziness) or be slightly out of focus. If the detection is inaccurate, you may need to adjust the preprocessing blur parameters in the notebook to improve accuracy.

  • Problem: The system detects the fabric texture (weave) as a defect.

  • Solution: Increase the Gaussian Blur kernel size in the preprocessing step (e.g., change (3,3) to (5,5) or (7,7)). This smooths out the background texture.

  • Problem: The defect is blurry and not detected.

  • Solution: Decrease the blur level or apply a Sharpening Filter using OpenCV before Gabor processing to enhance the defect edges.

Contributing

Contributions to improve the segmentation thresholding or to integrate a CNN-based classifier for comparison are welcome!

License

This project is open-source and available under the MIT License.

About

Automated surface defect detection system utilizing Gabor Filter Banks for robust texture analysis and anomaly segmentation.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors