Vectorized region-property features (skimage-compatible) via a single scatter pass.
Project description
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 asskimage.measure.regionprops_table:labelandbbox. -
label_imagemust be an integer 2D or 3D label image. Boolean and floating point inputs are rejected as ambiguous; labels<= 0are ignored. -
intensity_imagemay have the same shape aslabel_image, or one extra trailing channel axis. Multichannel intensity columns follow skimage naming, for exampleintensity_mean-0,intensity_mean-1. -
border_distis an extra property (not in skimage): the per-label max of a field that fades from 1 at the image border to 0 onceborder_dist_cutoffpx away (last two axes only). -
properties needing a convex hull / perimeter / topology (
solidity,perimeter,euler_number, etc.) are not yet supported.
License
BSD-3-Clause.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
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 fast_regionprops-0.1.0.tar.gz.
File metadata
- Download URL: fast_regionprops-0.1.0.tar.gz
- Upload date:
- Size: 12.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
869071dd0c41a798189ee3d17763c9c0c661e149625ec500207560756bc273bd
|
|
| MD5 |
7c6b010df1ee4db9042bee6c073ff8c0
|
|
| BLAKE2b-256 |
e9c0d95b70302dad9510c89b13b1575879f07e42ed5cadf55e4132e93fe08f9b
|
Provenance
The following attestation bundles were made for fast_regionprops-0.1.0.tar.gz:
Publisher:
publish.yml on maweigert/fast-regionprops
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
fast_regionprops-0.1.0.tar.gz -
Subject digest:
869071dd0c41a798189ee3d17763c9c0c661e149625ec500207560756bc273bd - Sigstore transparency entry: 1859757438
- Sigstore integration time:
-
Permalink:
maweigert/fast-regionprops@89c6741209d9a4057b29da2ebccae09a2ce4c770 -
Branch / Tag:
refs/tags/v0.1.0 - Owner: https://github.com/maweigert
-
Access:
private
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@89c6741209d9a4057b29da2ebccae09a2ce4c770 -
Trigger Event:
push
-
Statement type:
File details
Details for the file fast_regionprops-0.1.0-py3-none-any.whl.
File metadata
- Download URL: fast_regionprops-0.1.0-py3-none-any.whl
- Upload date:
- Size: 7.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
5d6615b7065666a6ab3a43a12c881a188b21394c4b45b52fc1e196b935ac9dd2
|
|
| MD5 |
b7271bf74a266aa920c6023bf433dc38
|
|
| BLAKE2b-256 |
708de7e7a6e9ce0a19c2383890b443ced9caea11fddba3060883add111709582
|
Provenance
The following attestation bundles were made for fast_regionprops-0.1.0-py3-none-any.whl:
Publisher:
publish.yml on maweigert/fast-regionprops
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
fast_regionprops-0.1.0-py3-none-any.whl -
Subject digest:
5d6615b7065666a6ab3a43a12c881a188b21394c4b45b52fc1e196b935ac9dd2 - Sigstore transparency entry: 1859757446
- Sigstore integration time:
-
Permalink:
maweigert/fast-regionprops@89c6741209d9a4057b29da2ebccae09a2ce4c770 -
Branch / Tag:
refs/tags/v0.1.0 - Owner: https://github.com/maweigert
-
Access:
private
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@89c6741209d9a4057b29da2ebccae09a2ce4c770 -
Trigger Event:
push
-
Statement type: