Skip to main content

fast-regionprops

A faster (vectorized) version of regionprops that supports a subset of region-property features, yielding a typical ~10-80× speedup (especially for many regions). Can be used as a drop-in replacement for skimage.measure.regionprops_table for the following set of properties:

label, area, centroid, bbox, equivalent_diameter_area,
intensity_mean, intensity_min, intensity_max, intensity_std,
inertia_tensor, border_dist
Dim Image size #Regions skimage (ms) fast (ms) Speedup
2D 512×512 100 10.5 0.4 26.8×
2D 512×512 400 40.8 0.5 77.8×
2D 1024×1024 1600 163.1 2.0 82.8×
2D 2048×2048 3600 368.7 6.5 57.0×
3D 128×128×128 512 76.5 3.3 23.5×
3D 256×256×256 1728 229.6 19.6 11.7×

Install

pip install fast-regionprops
# dev / tests
pip install -e ".[test]"
# dev / tests / pre-commit
pip install -e ".[dev]"
pre-commit install

Usage

import numpy as np
from skimage.data import binary_blobs
from skimage.measure import label

from fast_regionprops import regionprops_table_fast

# example data: blobs as mask, random image as intensity
mask = label(binary_blobs(length=512, blob_size_fraction=0.05, volume_fraction=0.1))
intensity = np.random.default_rng(0).random(mask.shape).astype("float32")

# drop-in for skimage.measure.regionprops_table (same column names)
table = regionprops_table_fast(
    mask,
    intensity,
    properties=("label", "area", "centroid", "intensity_mean", "inertia_tensor"),
)
table["centroid-0"], table["inertia_tensor-0-1"]   # 1D arrays, one row per label

Output is a dict[str, np.ndarray] (same as for skimage.measure.regionprops_table)

Property notes

  • Calling regionprops_table_fast(label_image) uses the same default properties as skimage.measure.regionprops_table: label and bbox.

  • label_image must be an integer 2D or 3D label image. Boolean and floating point inputs are rejected as ambiguous; labels <= 0 are ignored.

  • intensity_image may have the same shape as label_image, or one extra trailing channel axis. Multichannel intensity columns follow skimage naming, for example intensity_mean-0, intensity_mean-1.

  • border_dist is an extra property (not in skimage): the minimum pixel distance from each label to any image border. The per-axis distances are returned as border_dist-0, border_dist-1, and, for 3D images, border_dist-2.

  • properties needing a convex hull / perimeter / topology (solidity, perimeter, euler_number, etc.) are not yet supported.

License

BSD-3-Clause.

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

fast_regionprops-0.2.0.tar.gz (11.9 kB view details)

Uploaded Source

Built Distribution

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

fast_regionprops-0.2.0-py3-none-any.whl (6.9 kB view details)

Uploaded Python 3

File details

Details for the file fast_regionprops-0.2.0.tar.gz.

File metadata

  • Download URL: fast_regionprops-0.2.0.tar.gz
  • Upload date:
  • Size: 11.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for fast_regionprops-0.2.0.tar.gz
Algorithm Hash digest
SHA256 058958e227eae053c389a3d007a75de03587c78756dfccf1b11e58e087e12d98
MD5 15a1ed6bed0843dfcbd9efe6f2b0b47c
BLAKE2b-256 9d256b5f2e50cbdd7c92a4cbf32b8974065d44f70ab4dfde43ada13cc986afc6

See more details on using hashes here.

Provenance

The following attestation bundles were made for fast_regionprops-0.2.0.tar.gz:

Publisher: publish.yml on maweigert/fast-regionprops

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file fast_regionprops-0.2.0-py3-none-any.whl.

File metadata

File hashes

Hashes for fast_regionprops-0.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 afa9e96871d3de56c55c90d47563f85d0fa7990668ce33aeeea7189290535ca0
MD5 9bf31e42a8492c1e470b34b960bc6905
BLAKE2b-256 5004b0f4d0d908e1e833ba694850349e31337e1a0d4eabc15b568d74b0ab588c

See more details on using hashes here.

Provenance

The following attestation bundles were made for fast_regionprops-0.2.0-py3-none-any.whl:

Publisher: publish.yml on maweigert/fast-regionprops

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Release history Release notifications | RSS feed

This release

0.2.0 This release

2 files

0.1.0

2 files

Supported by

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