Skip to main content

digitopo logo: a ring of pixels and, in orange, its skeleton

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, lskelcurv and lskelcurv3d, 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 without inhibit (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.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for digitopo 0.1.1
File Size Uploaded Provenance Actions
digitopo-0.1.1.tar.gz 166.9 kB With provenance Details for digitopo-0.1.1.tar.gz

Built distributions (wheels)

Table of built distributions (wheels) for digitopo 0.1.1
File Actions
digitopo-0.1.1-cp311-abi3-win_amd64.whl CPython 3.11 abi3 Windows x86-64 Details for digitopo-0.1.1-cp311-abi3-win_amd64.whl
digitopo-0.1.1-cp311-abi3-musllinux_1_2_x86_64.whl CPython 3.11 abi3 Linux musl 1.2+ x86-64 Details for digitopo-0.1.1-cp311-abi3-musllinux_1_2_x86_64.whl
digitopo-0.1.1-cp311-abi3-musllinux_1_2_aarch64.whl CPython 3.11 abi3 Linux musl 1.2+ ARM64 Details for digitopo-0.1.1-cp311-abi3-musllinux_1_2_aarch64.whl
digitopo-0.1.1-cp311-abi3-manylinux2014_x86_64.manylinux_2_17_x86_64.whl CPython 3.11 abi3 Linux glibc 2.17+ x86-64 Details for digitopo-0.1.1-cp311-abi3-manylinux2014_x86_64.manylinux_2_17_x86_64.whl
digitopo-0.1.1-cp311-abi3-manylinux2014_aarch64.manylinux_2_17_aarch64.whl CPython 3.11 abi3 Linux glibc 2.17+ ARM64 Details for digitopo-0.1.1-cp311-abi3-manylinux2014_aarch64.manylinux_2_17_aarch64.whl
digitopo-0.1.1-cp311-abi3-macosx_11_0_arm64.whl CPython 3.11 abi3 macOS 11.0+ ARM64 Details for digitopo-0.1.1-cp311-abi3-macosx_11_0_arm64.whl
digitopo-0.1.1-cp311-abi3-macosx_10_12_x86_64.whl CPython 3.11 abi3 macOS 10.12+ x86-64 Details for digitopo-0.1.1-cp311-abi3-macosx_10_12_x86_64.whl

Total release size: 4.7 MB

Release files / digitopo-0.1.1.tar.gz

Download URL digitopo-0.1.1.tar.gz
Size 166.9 kB
Tags Source
SHA-256 checksum
How to use checksums
8a192cafcfc3d6c40419a7a4743a17eddd2300f4833236e1e3fb8db4b7335b9f
BLAKE2b-256 checksum
How to use checksums
2c64bd691464cdaf2f5ecfe74bcbcdfd6230b358736c6040519f52ce9236673d
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 3, 2026.

Transparency log

Release files / digitopo-0.1.1-cp311-abi3-win_amd64.whl

Download URL digitopo-0.1.1-cp311-abi3-win_amd64.whl
Size 524.1 kB
Tags CPython 3.11 Windows x86-64 abi3
SHA-256 checksum
How to use checksums
d239e2fc63fccca0ad96aa8a5ef3849120492e8ddafc402faba0722c08a625eb
BLAKE2b-256 checksum
How to use checksums
a1e13425be06960cb6e177ace7eb32b31b8b48e74e008d5f0c525285ff8d0d7f
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 3, 2026.

Transparency log

Release files / digitopo-0.1.1-cp311-abi3-musllinux_1_2_x86_64.whl

Download URL digitopo-0.1.1-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
4f2ef9a057f06ff337a525d78e93eb93b09bbcce49d457524b97fdf4f402df00
BLAKE2b-256 checksum
How to use checksums
3e53d7fffb4bd0495500ec5f428695007aa0f280635c8088871043e0fa23e33c
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 3, 2026.

Transparency log

Release files / digitopo-0.1.1-cp311-abi3-musllinux_1_2_aarch64.whl

Download URL digitopo-0.1.1-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
113007967ff400e05cd29453f4c6dd2c5522ea6116df8c26ab3fefed6aff1c0a
BLAKE2b-256 checksum
How to use checksums
4852986d35eb049ad791c9d62abe7c84c7deb4c0fe46e41fd9a8edc14579bc5d
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 3, 2026.

Transparency log

Release files / digitopo-0.1.1-cp311-abi3-manylinux2014_x86_64.manylinux_2_17_x86_64.whl

Download URL digitopo-0.1.1-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
cead4a6bab8896f60ec9188a3c66baf47bcc30f4884a023f52bc635fce133cec
BLAKE2b-256 checksum
How to use checksums
857fdcdf608c9469070544db1c1b7f06f99f1d39c0daf69678518dc3c879fae3
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 3, 2026.

Transparency log

Release files / digitopo-0.1.1-cp311-abi3-manylinux2014_aarch64.manylinux_2_17_aarch64.whl

Download URL digitopo-0.1.1-cp311-abi3-manylinux2014_aarch64.manylinux_2_17_aarch64.whl
Size 598.5 kB
Tags CPython 3.11 Linux glibc 2.17+ ARM64 abi3
SHA-256 checksum
How to use checksums
40ed58a53b82060cfd18c661b090255c9139321f698485881e8ba6b1dec8eafc
BLAKE2b-256 checksum
How to use checksums
53dc599d976d0434056e4cdcc224a4bc435db84b70b9a8ef86e0c4a914ecfb33
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 3, 2026.

Transparency log

Release files / digitopo-0.1.1-cp311-abi3-macosx_11_0_arm64.whl

Download URL digitopo-0.1.1-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
7a7373d225a722894c1680e69bcbb0d454fddd1c6045aab8b1629200c49405b3
BLAKE2b-256 checksum
How to use checksums
359280367c0f91c7f2e00a00be4110ff747ebb90666997bed95472afc040a6fd
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 3, 2026.

Transparency log

Release files / digitopo-0.1.1-cp311-abi3-macosx_10_12_x86_64.whl

Download URL digitopo-0.1.1-cp311-abi3-macosx_10_12_x86_64.whl
Size 578.7 kB
Tags CPython 3.11 abi3 macOS 10.12+ x86-64
SHA-256 checksum
How to use checksums
26731139ab0abb2b970454a10405a664eb6cd052d453293f8372e43bd5f364c6
BLAKE2b-256 checksum
How to use checksums
02668974a499f9f62c63db2a737c199414841a0641aff752f725c556e6c7286a
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 3, 2026.

Transparency log

Security for digitopo 0.1.1

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.

Select from 8 files

Attestation for digitopo-0.1.1.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 3, 2026.

Transparency log

A 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.

Release history Release notifications | RSS feed

This release

0.1.1 This release

8 release files Full provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page