Metallic and ceramic grain analysis made easy.

computer-vision, materials-science, opencv
pip install grains==0.1.0



grains is a software package for the tens of tech savy metallurgists and ceramists out there who are tired of counting grains by hand. The goal of this project is to accelerate the process of grain analysis by applying modern computer vision algorithms. This package does not yet have a stable release.


This example showcases the basic functionality of the grains software library. Please note that the scale in this example is ARBITRARY as I have not yet found adequate validation images. Refer to the examples directory for the simple source code used to generate these results.

Input Image

Centroids Image - Default Settings

Area Histogram - Default Settings

Text Summarization - Default Settings

Automatically Generated by grains

Input filename: test_grains.jpg
Number of grains: 40
Grain area mean: 1631.55 um^2
Grain area variance: 1527136.86 um^2
Grain area standard deviation: 1235.77 um^2


  • Grain counter with OpenCV

  • Size distribution analysis

  • Calculate average grain size in accordance with ASTM E112

  • Validate performance against relevant literature

  • Wrap functionality into a simple CLI

  • Package for pip install