Skip to content

Traditional, rule-based pipeline for assessing electrode degradation in microscope images using OpenCV + scikit-image; includes illumination correction, CLAHE, adaptive thresholding, mask logic, delamination Length, covered Length, uncovered length, overall length, substrate Covered length and contour based length quantification with CSV/PNG output

Notifications You must be signed in to change notification settings

Faheem8585/Classical-Image-processing-pipeline-

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 

Repository files navigation

Electrode Degradation — Traditional Image Processing Pipeline

License: MIT Python OpenCV NumPy Matplotlib pandas scikit--image

This repository contains the baseline, rule-based pipeline used to assess electrode degradation from high-resolution microscope images. It sets a clear reference for performance before moving to data-driven methods. The implementation lives in the notebook Coating_defects_traditional.ipynb and uses OpenCV and scikit-image.

What the pipeline does

  • Preprocess images to correct uneven illumination and low local contrast.

  • Segment coating, substrate, and background into binary masks.

  • Post-process masks with morphology and Boolean logic to derive defect classes.

  • Detect delamination by intersecting dilated coating and substrate edges within background regions.

  • Quantify defect lengths from contours and export results to CSV.

  • Export visual overlays (PNGs) for each region.

Method (step-by-step)

  1. Load image

Set the input path (e.g., 10-11318_6050-PG_17_0310.jpg) and the pixel size (default 0.73 μm/pixel).

  1. Illumination correction (L channel)

Convert to LAB, take L, blur with a large Gaussian kernel (101×101), subtract, then normalize to [0, 255].

  1. Contrast enhancement (CLAHE)

Apply CLAHE (clipLimit=3.0, tileGridSize=25×25) to the normalized L image.

  1. Noise removal (before thresholding)

Use morphological opening with an elliptical kernel (5×5).

  1. Adaptive Gaussian thresholding

Compute separate masks with tuned parameters:

  • Coating:

binary (blockSize 11, C≈8)

  • Substrate:

inverse binary (e.g., blockSize 11–15, C≈8–10)

  • Background:

inverse binary (blockSize 11, C≈2)

  1. Morphological cleanup

Apply opening to each thresholded mask; optionally filter by connected-component area.

  1. Derived masks (Boolean logic)
  • Covered coating:

From cleaned coating mask.

  • Uncovered coating:

substrate_mask AND NOT coating_mask.

  • Overall coating:

union of covered and uncovered.

  1. Delamination detection

Dilate coating and substrate edges (3×3 rect kernel, iterations=2) and intersect them inside the background to get delaminated regions. Remove small components (e.g., area ≤220 px).

  1. Length measurement (μm)

Trace contours (skimage.measure.find_contours), draw polylines, sum segment lengths, and convert to microns using pixel_size.

  1. Outputs
  • CSV: e.g., Stack_Frontview19_length_results.csv with region-wise lengths.

  • PNG overlays per region (saved with region names).

Inputs and outputs

  1. Input:
  • A microscope image (e.g., .jpg/.png) placed in the repo or a /data folder.
  1. Outputs:
  • .png overlays for covered/overall coating and other regions.

  • _length_results.csv with two columns: Region, Length (μm).

Requirements

  • Python 3.9+

  • OpenCV, NumPy, Matplotlib, Pandas, scikit-image

About

Traditional, rule-based pipeline for assessing electrode degradation in microscope images using OpenCV + scikit-image; includes illumination correction, CLAHE, adaptive thresholding, mask logic, delamination Length, covered Length, uncovered length, overall length, substrate Covered length and contour based length quantification with CSV/PNG output

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages