Particle shape analysis and visualization library.
Project description
PartiMorph
PartiMorph analyzes a 2D binary particle mask and returns:
- Wadell roundness
- ISO circularity
- Riley sphericity
- Aspect ratio
Install
Python 3.12+
pip install -e .
Quick Start
import partimorph as pm
mask = pm.utils.create_circle_mask((256, 256), (128, 128), 60)
results = pm.analyze_mask(mask)
print(results["roundness"]["val"])
print(results["circularity"]["val"])
print(results["sphericity"]["val"])
print(results["aspect_ratio"]["val"])
Input Rules
maskmust be a 2Dnumpy.ndarray- Allowed values:
boolor{0, 1} - Empty mask returns
None
Main API
pm.analyze_mask(
mask,
use_aspect_ratio=True,
use_roundness=True,
use_circularity=True,
use_sphericity=True,
roundness_params=None,
eps=0.001,
target_dim=384,
)
Notes:
- Large masks are downscaled automatically (
target_dim) for speed. use_* = Falseremoves that metric from the output keys.
Result Shape
{
"roundness": {"val": float} | None,
"circularity": {"val": float} | None,
"sphericity": {
"val": float,
"inscribed": {"x": float, "y": float, "r": float},
"enclosing": {"x": float, "y": float, "r": float},
} | None,
"aspect_ratio": {
"val": float,
"ellipse": {
"major": float, "minor": float,
"x": float, "y": float, "angle": float,
"w": float, "h": float, "bbox": list[list[float]],
},
} | None,
}
Utilities
pm.utils.create_particle_mask(...): synthetic mask generatorpm.utils.plot_analysis_results(mask, results): quick visualization
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
partimorph-0.1.0.tar.gz
(15.9 kB
view details)
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file partimorph-0.1.0.tar.gz.
File metadata
- Download URL: partimorph-0.1.0.tar.gz
- Upload date:
- Size: 15.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
0ee68695664e2b6838fabaaa2155a10259ef75b7646fd58295dcbc52aa8c17ab
|
|
| MD5 |
b7f2addbb624b74a460beb0e7c73df9b
|
|
| BLAKE2b-256 |
01671bcdb9c3973b8533a5a70a0de11b03271903945774103103896dcc667baf
|
File details
Details for the file partimorph-0.1.0-py3-none-any.whl.
File metadata
- Download URL: partimorph-0.1.0-py3-none-any.whl
- Upload date:
- Size: 18.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
b81e5ab28a5a55b69ae056de8d9f00cb0911c8cee1081ee94511bca9d06dcde7
|
|
| MD5 |
a85c001bdf3b7151383be75779ab1187
|
|
| BLAKE2b-256 |
f6626a6dce9c3d611fc9a66f2ae797a3dbabe9fda5b422917bdff2337ee1a63a
|