Metadata-Version: 2.4
Name: pyPetrograph
Version: 0.0.6
Summary: Thin-section petrography: hand-label RGB features, mineral-map grain counts, and multi-image grain segmentation.
Author: Larry Syu-Heng Lai
License: AGPL-3.0-or-later
Project-URL: Homepage, https://github.com/GeoLarryLai/pyPetrograph
Project-URL: Repository, https://github.com/GeoLarryLai/pyPetrograph
Keywords: petrography,thin-section,mineralogy,segmentation,porosity
Classifier: Development Status :: 3 - Alpha
Classifier: Intended Audience :: Science/Research
Classifier: License :: OSI Approved :: GNU Affero General Public License v3 or later (AGPLv3+)
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Topic :: Scientific/Engineering :: GIS
Classifier: Topic :: Scientific/Engineering :: Image Processing
Requires-Python: >=3.10
Description-Content-Type: text/markdown
License-File: LICENSE
Requires-Dist: numpy>=1.24
Requires-Dist: pillow>=10
Requires-Dist: matplotlib>=3.7
Requires-Dist: scikit-learn>=1.3
Requires-Dist: scipy>=1.10
Requires-Dist: geopandas>=0.14
Requires-Dist: shapely>=2
Requires-Dist: rasterio>=1.3
Requires-Dist: affine>=2.4
Requires-Dist: joblib>=1.3
Requires-Dist: pandas>=2
Requires-Dist: lightgbm>=4
Requires-Dist: scikit-image>=0.22
Requires-Dist: PyQt5>=5.15
Provides-Extra: seg
Requires-Dist: tensorflow<2.22,>=2.16; extra == "seg"
Requires-Dist: keras>=3; extra == "seg"
Requires-Dist: segmenteverygrain==0.5.0; extra == "seg"
Provides-Extra: sam2
Requires-Dist: torch>=2.2; extra == "sam2"
Requires-Dist: torchvision; extra == "sam2"
Requires-Dist: sam2>=1.0; extra == "sam2"
Provides-Extra: xgb
Requires-Dist: xgboost>=2; extra == "xgb"
Provides-Extra: all
Requires-Dist: pyPetrograph[sam2,seg,xgb]; extra == "all"
Dynamic: license-file

# pyPetrograph

v0.0.6

[![PyPI version](https://img.shields.io/pypi/v/pypetrograph.svg)](https://pypi.org/project/pypetrograph/)

pyPetrograph is a machine-learning toolkit for thin-section petrography.

**Warning:** This tool is under development. Use with caution. APIs and numbers can still change.

## What it does

**Hand-label features and map their area %.** Paint a few examples of each class you care about (pores, grains, cement, …) from color, edge sharpness, and microtexture. A LightGBM pixel classifier (random forest or XGBoost optional) maps the rest of the photo and reports area % of each class.

**Count grains on a painted mineral map.** Match pixels to a color legend, split grains that touch, and count how many grains sit in each class.

**Segment grains from a multi-image overlay.** Line up several image types of the same field (plane-polarized light, crossed polars, or others) and refine grain outlines with a U-Net, so boundaries are not drawn from one lighting alone.

For finer grain-boundary mapping there is optional support for [SegmentEveryGrain](https://github.com/zsylvester/segmenteverygrain) (Zoltan Sylvester). [SAM 2.1](https://github.com/facebookresearch/sam2) weights (~860 MB) are a further opt-in on their page, not part of the default install.

## Install

```bash
pip install pypetrograph
```

```bash
pip install segmenteverygrain
```

The second line is optional (SegmentEveryGrain’s existing-environment path).

## Demos

Example notebooks, test images, and figures are in the [GitHub repository](https://github.com/GeoLarryLai/pyPetrograph).

## Credits

The current version is primarily developed by **Larry Syu-Heng Lai**, based on early source code scripted by **Zoltan Sylvester**, at the Quantitative Clastic Laboratory, Bureau of Economic Geology, The University of Texas at Austin. This development is also part of a collaboration with **Priyanka Periwal**, **Lucy Tingwei Ko**, **Kelly Hattori**, and **Amanda Calle** across multiple research groups and the [e-MAGE lab](https://www.beg.utexas.edu/research/labs/sem) in the Bureau of Economic Geology.

## License

GNU Affero General Public License 3.0 or later (`LICENSE`).
