digitopo
Digital topology operators for binary and grey-level images in 2D and 3D (simple points also in 4D), written in Rust with a NumPy interface.
Status: beta. Every public function of pink26 is provided, with identical results point by point.
Installation
pip install digitopo
Wheels are provided for Linux, macOS and Windows, for Python 3.11 and later; NumPy is the only dependency. Building from the source needs a Rust toolchain (1.88 or later).
Documentation: https://alainlebret.github.io/digitopo/. Source and issues: https://github.com/alainlebret/digitopo.
What it does
The public API is that of pink26 (same modules, functions, parameters and codes), and the results are identical point by point. See docs/API.md.
| Module | Functions |
|---|---|
digitopo.topology |
topological_numbers, simple_points (2D to 4D), point_types, point_classes_3d, end_points, curve_points, junction_points, euler_characteristic, topology |
digitopo.distance |
distance_map: squared Euclidean, 5-7 chamfer, d4, d8, d6, d18, d26 |
digitopo.io |
read, write: Pink's PGM format (2D and 3D; uint8, int32, float32, float64), the bytes of pink26 |
digitopo.skeleton |
ultimate_skeleton, curvilinear_skeleton (with priority and inhibit), parallel_skeleton (critical kernels: ultimate, curvilinear, surface; symmetric or not), zhang_wang_thinning, guo_hall_thinning (classic 2D parallel thinnings, for comparison) |
digitopo.watershed |
topological_watershed, watershed_lines, watershed_labels (labelled basins, as skimage.segmentation.watershed; no equivalent in pink26) |
digitopo.grayscale |
homotopic_thinning, homotopic_thickening, homotopic_kernel, lambda_kernel |
digitopo.evaluation |
topology_errors, cl_dice (no equivalent in pink26) |
digitopo.measure |
branches: branches of a skeleton, their kinds and physical lengths; prune: removal of short spurs (no equivalent in pink26) |
digitopo.interop |
connectivity, skimage_connectivity, as_uint8: the conventions of scikit-image (no equivalent in pink26) |
The connectivity of the object is mandatory: 4 or 8 in 2D, 6 or 26 in 3D (8 or 80 in 4D for simple_points); the background uses the complementary one. 18 is refused, except by the watershed functions (6, 18 or 26 in 3D). digitopo.connectivity(ndim, c) converts a connectivity of scikit-image (1 to ndim). The grey-level functions take uint8 images, or, with convert=True, the float images of scikit-image.
import numpy as np
from digitopo import skeleton, topology
y, x = np.ogrid[-12:13, -12:13]
ring = (x**2 + y**2 <= 100) & (x**2 + y**2 >= 25)
curve = skeleton.ultimate_skeleton(ring, 8) # a closed curve
print(topology.topology(curve, 8)) # Topology(objects=1, holes=1, cavities=0, euler=0)
Method
- Simple points: Theorem 15 of Couprie and Bertrand (2009). A pixel is a closed unit square (a voxel, a unit cube). Its attachment is the set of faces of its boundary that it shares with the rest of the object. For d = 2, 3, 4, the point is simple if and only if the attachment is connected, the rest of the boundary is connected, and the Euler characteristic of the attachment equals 1. The small connectivities (4, 6) follow by duality.
- Topological numbers and point classes: Bertrand (1994), Malandain, Bertrand and Ayache (1993).
- Skeletons: the points are examined in the order of Pink's
lskelubp2,lskelubp3d2,lskelcurvandlskelcurv3d, including Pink's red-black tree and its reallocations (src/pink_rbt.rs), so that equal priorities are resolved as in Pink.
Verification
- All 256 2D and all 2^26 (67 108 864) 3D configurations: the simplicity test of Couprie and Bertrand agrees with the topological numbers, for both connectivities (
cargo test --release -- --ignored all_3d, about 4 s). - Python tests against independent references: a NumPy computation of the topological numbers, SciPy labelling,
skimage.measure.euler_number. tests/python/test_oracle_pink26.py: every function of the API compared point by point with pink26, in 2D and 3D, for the four connectivities, on smooth and noisy random images, with the default, integer and float priorities, with and withoutinhibit(skipped when pink26 is not installed).
Measured with benches/compare_pink26.py on a laptop with 11 cores (Apple M3 Pro), digitopo 0.1.0 against pink26 0.1.1: best of 5 runs (3 for the grey-level operators), connectivity 8 in 2D and 26 in 3D. The results are identical to pink26 in every case. Gain is the time of pink26 divided by the time of digitopo on 11 threads, its default. pink26 runs on one core: the 1 thread column (RAYON_NUM_THREADS=1) separates what comes from the algorithms from what comes from the cores.
| Image | Function | pink26 | digitopo, 1 thread | digitopo, 11 threads | Gain |
|---|---|---|---|---|---|
| 3D 128^3 | simple_points |
1.09 s | 0.044 s | 0.007 s | 156x |
| 3D 128^3 | point_types |
1.10 s | 0.12 s | 0.015 s | 73x |
| 2D 1024 x 1024 | ultimate_skeleton |
0.18 s | 0.18 s | 0.17 s | 1.1x |
| 3D 128^3 | ultimate_skeleton |
1.56 s | 0.71 s | 0.66 s | 2.4x |
| 3D 128^3 | curvilinear_skeleton |
12.3 s | 2.04 s | 1.89 s | 6.5x |
| 2D 1024 x 1024 | parallel_skeleton (ultimate, symmetric) |
1.88 s | 2.44 s | 0.38 s | 5.0x |
| 3D 128^3 | parallel_skeleton (ultimate, symmetric) |
4.29 s | 1.48 s | 0.87 s | 4.9x |
| 2D 1024 x 1024 | topological_watershed |
0.61 s | 0.28 s | 0.28 s | 2.2x |
| 3D 128^3 | topological_watershed |
6.32 s | 3.21 s | 3.43 s | 1.8x |
| 3D 64^3 | homotopic_kernel |
2.03 s | 0.22 s | 0.22 s | 9.3x |
| 3D 64^3 | homotopic_thinning |
16.2 s | 2.09 s | 2.09 s | 7.8x |
| 3D 128^3 | distance_map (d26) |
0.17 s | 0.045 s | 0.045 s | 3.7x |
| 2D 1024 x 1024 | zhang_wang_thinning |
0.072 s | 0.048 s | 0.048 s | 1.5x |
The gains come from the algorithms and from the cores, not from Rust itself: compare the 1 thread column with pink26. The full table, with every function, is in the documentation (Correspondence with pink26, Speed).
The point-by-point functions, the Euler characteristic and the distance map run on all cores (rayon); set RAYON_NUM_THREADS to limit them. The sequential skeletons follow Pink's order point after point and use one core, apart from their distance map.
In 3D, the simplicity test uses Bertrand's topological numbers with early exits, which is faster than the cube test of Couprie and Bertrand and equal to it on all 2^26 configurations (exhaustive test); the cube test remains the reference, and serves in 4D.
Development
cargo test --release # Rust tests
pip install -e ".[test]" # build the extension (maturin) and install
pytest # Python tests (the pink26 oracle tests need pink26)
Continuous integration, wheels for Linux, macOS and Windows, and releases: see docs/RELEASING.md.
Documentation: pip install ".[docs]" then mkdocs build --strict (or mkdocs serve) builds the site from docs/ and mkdocs.yml; .github/workflows/docs.yml publishes it on GitHub Pages.
Licence
CeCILL v2.1 (LICENSE, French version in LICENCE-fr), a free software licence compatible with the GNU GPL.
The code is Copyright Alain Lebret (2026). The operators ported from Pink through pink26 (src/pink_rbt.rs, src/skeleton.rs, src/parallel2d.rs, src/parallel3d.rs, src/grayscale.rs, src/watershed.rs, src/queue.rs) also carry Pink's notice, Copyright ESIEE (2009); pink26 distributes Pink under CeCILL v2.0, whose article 12.3 allows a later version of the licence, such as v2.1.
Credits
Based on the work of Gilles Bertrand and Michel Couprie (ESIEE Paris, LIGM) on digital topology, and on Pink, their image processing library. pink26, the C11 and Python update of Pink, serves as the reference for the tests.
References
- M. Couprie and G. Bertrand, "New characterizations of simple points in 2D, 3D and 4D discrete spaces", IEEE Transactions on Pattern Analysis and Machine Intelligence, 31(4):637-648, 2009. hal-00622393
- G. Bertrand, "Simple points, topological numbers and geodesic neighborhoods in cubic grids", Pattern Recognition Letters, 15:1003-1011, 1994.
Metadata
Release files for digitopo 0.1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| digitopo-0.1.0.tar.gz | 165.8 kB | With provenance | Details for digitopo-0.1.0.tar.gz |
Built distributions (wheels)
Total release size: 4.7 MB
Release files / digitopo-0.1.0.tar.gz
| Download URL | digitopo-0.1.0.tar.gz |
|---|---|
| Size | 165.8 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
6138518481b751e69156932fd716d5b7a04b366380360571352331d26a9cef6c
|
|
BLAKE2b-256 checksum How to use checksums |
3906ff9c7019b8e9571b1c4e708cb432c8e0c3a0b7d84d7efb9005b8cfdb0a52
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Dec 1, 2026.
Transparency logRelease files / digitopo-0.1.0-cp311-abi3-win_amd64.whl
| Download URL | digitopo-0.1.0-cp311-abi3-win_amd64.whl |
|---|---|
| Size | 524.1 kB |
| Tags | CPython 3.11 Windows x86-64 abi3 |
|
SHA-256 checksum How to use checksums |
3c05a607ae5bd3c266f14fa9113554580047383e03c60de8fbba77191ce3d0e2
|
|
BLAKE2b-256 checksum How to use checksums |
14058b90f0eec010646ed708ed96b2ca5870855d76d5dcd721dcfa8873b4973e
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Dec 1, 2026.
Transparency logRelease files / digitopo-0.1.0-cp311-abi3-musllinux_1_2_x86_64.whl
| Download URL | digitopo-0.1.0-cp311-abi3-musllinux_1_2_x86_64.whl |
|---|---|
| Size | 831.9 kB |
| Tags | CPython 3.11 Linux musl 1.2+ x86-64 abi3 |
|
SHA-256 checksum How to use checksums |
80bd56d5d26501160d8e46ee7242d26b24dabbdb2098a58b70fb4ddf8e7e330e
|
|
BLAKE2b-256 checksum How to use checksums |
138a9c8ac4a8696c93b1497e092de9ad38b67c2a660b4060ba70607bf7d1f6e3
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Dec 1, 2026.
Transparency logRelease files / digitopo-0.1.0-cp311-abi3-musllinux_1_2_aarch64.whl
| Download URL | digitopo-0.1.0-cp311-abi3-musllinux_1_2_aarch64.whl |
|---|---|
| Size | 775.8 kB |
| Tags | CPython 3.11 Linux musl 1.2+ ARM64 abi3 |
|
SHA-256 checksum How to use checksums |
76e6bd42972551a9a30eb4493efc29711a876ecfd57a7b516c7438b29671d721
|
|
BLAKE2b-256 checksum How to use checksums |
c0d5cc09b5b6e081929d2d5402f202456e50e94d911ffbf5286debf4b47bcb47
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Dec 1, 2026.
Transparency logRelease files / digitopo-0.1.0-cp311-abi3-manylinux2014_x86_64.manylinux_2_17_x86_64.whl
| Download URL | digitopo-0.1.0-cp311-abi3-manylinux2014_x86_64.manylinux_2_17_x86_64.whl |
|---|---|
| Size | 620.3 kB |
| Tags | CPython 3.11 Linux glibc 2.17+ x86-64 abi3 |
|
SHA-256 checksum How to use checksums |
6b5deaa6dbe23c8ed59d56b5077a2e206e982b55d413052e4fccfcc0b7168ad3
|
|
BLAKE2b-256 checksum How to use checksums |
ca6d0d325de6e21b738301fcf8d7da4e50a3e9a057db3030c78d2627a8c2d8ca
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Dec 1, 2026.
Transparency logRelease files / digitopo-0.1.0-cp311-abi3-manylinux2014_aarch64.manylinux_2_17_aarch64.whl
| Download URL | digitopo-0.1.0-cp311-abi3-manylinux2014_aarch64.manylinux_2_17_aarch64.whl |
|---|---|
| Size | 598.4 kB |
| Tags | CPython 3.11 Linux glibc 2.17+ ARM64 abi3 |
|
SHA-256 checksum How to use checksums |
c2961c963f867aa379d51d9ecc2c7b05370e87a30977a9a0fd139a1d63f853ea
|
|
BLAKE2b-256 checksum How to use checksums |
ed7239afe9de4996b38e8301644dccb29109307ceb2a31e490b4ea52b2f1184d
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Dec 1, 2026.
Transparency logRelease files / digitopo-0.1.0-cp311-abi3-macosx_11_0_arm64.whl
| Download URL | digitopo-0.1.0-cp311-abi3-macosx_11_0_arm64.whl |
|---|---|
| Size | 568.7 kB |
| Tags | CPython 3.11 abi3 macOS 11.0+ ARM64 |
|
SHA-256 checksum How to use checksums |
2a38ad256cf712307f6af06b156e8ca92a5f5becf9cca4f7677225b3e257d5e2
|
|
BLAKE2b-256 checksum How to use checksums |
97808666a89d19a066d9975767c57dfc67def2214dd94cde7313fcf07ff83393
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Dec 1, 2026.
Transparency logRelease files / digitopo-0.1.0-cp311-abi3-macosx_10_12_x86_64.whl
| Download URL | digitopo-0.1.0-cp311-abi3-macosx_10_12_x86_64.whl |
|---|---|
| Size | 578.8 kB |
| Tags | CPython 3.11 abi3 macOS 10.12+ x86-64 |
|
SHA-256 checksum How to use checksums |
22ae7cb55cc4340e86ffa60cb55ee6438e3f8ed224df40cae960d46fee276ce3
|
|
BLAKE2b-256 checksum How to use checksums |
73184c803dffba4c7f289acfe7a481526f2a477e23a37a053bcfceb8d36d8842
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Dec 1, 2026.
Transparency logSecurity for digitopo 0.1.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
Full provenance
All 8 files in this release have been uploaded with provenance metadata.
Attestation for digitopo-0.1.0.tar.gz
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Dec 1, 2026.
Transparency logA note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.