Skip to main content

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

  • mask must be a 2D numpy.ndarray
  • Allowed values: bool or {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_* = False removes 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 generator
  • pm.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)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

partimorph-0.1.0-py3-none-any.whl (18.3 kB view details)

Uploaded Python 3

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

Hashes for partimorph-0.1.0.tar.gz
Algorithm Hash digest
SHA256 0ee68695664e2b6838fabaaa2155a10259ef75b7646fd58295dcbc52aa8c17ab
MD5 b7f2addbb624b74a460beb0e7c73df9b
BLAKE2b-256 01671bcdb9c3973b8533a5a70a0de11b03271903945774103103896dcc667baf

See more details on using hashes here.

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

Hashes for partimorph-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 b81e5ab28a5a55b69ae056de8d9f00cb0911c8cee1081ee94511bca9d06dcde7
MD5 a85c001bdf3b7151383be75779ab1187
BLAKE2b-256 f6626a6dce9c3d611fc9a66f2ae797a3dbabe9fda5b422917bdff2337ee1a63a

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page