Back to blog
2026-04-02 5 min

Segmenting Grain Boundaries in 316L Steel with Computer Vision

Computer VisionU-NetMaterials Science

Grain size directly affects the mechanical properties of stainless steel, but measuring it by hand from micrographs is slow and inconsistent between operators. The goal of this project was to automate that measurement from 500x micrographs of 316L steel.

I compared four segmentation approaches: classical thresholding, gradient-based filters, the HED edge detector (via Caffe/OpenCV), and a U-Net trained on a mix of real and synthetic micrographs. The U-Net produced the cleanest, most continuous grain boundaries, especially on noisier images.

After segmentation, a pixel-to-micron calibration step converts the raw mask into physical units, producing grain size distributions, mean areas and circularity statistics — all accessible through a small Gradio interface so the results can be explored without touching any code.