waterz
Pronounced water-zed. A simple watershed and region agglomeration library for affinity graphs.
Based on the watershed implementation of Aleksandar Zlateski and Chandan Singh.
Install
pip install waterz
The wheels on PyPI contain waterz.evaluate and waterz.agglomerate,
precompiled for the most common scoring functions (see below). No compiler is
needed to use those.
Scoring functions
The scoring_function and discretize_queue arguments of agglomerate are
C++ template parameters, such that each combination is a separate compiled
module. The following are precompiled, each with discretize_queue=0 and
discretize_queue=256:
OneMinus<MeanAffinity<RegionGraphType, ScoreValue>>(the default)OneMinus<HistogramQuantileAffinity<RegionGraphType, Q, ScoreValue, 256, B>>forQin 10, 15, 20, ..., 95 andBintrue,false(andOneMinus<HistogramQuantileAffinity<RegionGraphType, Q, ScoreValue, 256>>, which is the same asB = true)Divide<Subtract<MaxSize<RegionGraphType>, MinSize<RegionGraphType>>, Add<MaxSize<RegionGraphType>, MinSize<RegionGraphType>>>(the relative difference of the region sizes, ignoring the affinities)
Any other combination is compiled the first time it is used, which requires a
C++ compiler and the boost headers (see below). The compiled module is cached
(in the cache directory of witty, which can
be set with WITTY_CACHE_DIR).
Set WATERZ_NO_PREBUILT=1 to compile all scoring functions on first use,
ignoring the precompiled ones.
Install locally
Install c++ dependencies:
# linux
sudo apt install libboost-dev
# macos
brew install boost
# windows
vcpkg install boost-multi-array:x64-windows
If boost is installed elsewhere, point BOOST_ROOT (or BOOST_INCLUDEDIR) to it.
Then
# make and activate env then:
pip install -e .
or
uv sync
Set WATERZ_NO_PREBUILT=1 to skip precompiling the scoring functions (all of
them are then compiled on first use), which makes for a faster build. After
changing the C++, run uv sync (or pip install -e .) again: the precompiled
modules do not notice, the compiled-on-first-use ones do.
Usage
import waterz
import numpy as np
# affinities is a [3,depth,height,width] numpy array of float32
affinities = ...
thresholds = [0, 100, 200]
segmentations = waterz.agglomerate(affinities, thresholds)
Development
Release to pypi
The version is derived from the git tag. Pushing a tag builds the wheels, tests them, and publishes them to PyPI:
git tag -a v0.9.7 -m v0.9.7
git push upstream --follow-tags
Metadata
Release files for waterz 0.10.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| waterz-0.10.1.tar.gz | 42.4 kB | Details |
Built distributions (wheels)
| File | Reset | |||
|---|---|---|---|---|
| waterz-0.10.1-cp311-abi3-win_amd64.whl | CPython 3.11 | abi3 | Windows x86-64 | Details |
| waterz-0.10.1-cp311-abi3-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl | CPython 3.11 | abi3 | Linux glibc 2.24+ x86-64, Linux glibc 2.28+ x86-64 | Details |
| waterz-0.10.1-cp311-abi3-manylinux_2_24_aarch64.manylinux_2_28_aarch64.whl | CPython 3.11 | abi3 | Linux glibc 2.28+ ARM64, Linux glibc 2.24+ ARM64 | Details |
| waterz-0.10.1-cp311-abi3-macosx_11_0_arm64.whl | CPython 3.11 | abi3 | macOS 11.0+ ARM64 | Details |
| waterz-0.10.1-cp311-abi3-macosx_10_9_x86_64.whl | CPython 3.11 | abi3 | macOS 10.9+ x86-64 | Details |
Total release size: 2.3 MB
Release files / waterz-0.10.1.tar.gz
| Download URL | waterz-0.10.1.tar.gz |
|---|---|
| Size | 42.4 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
31e116670399b074c7defedd7ba9234fb1cd9d1613edc641a8032c5d2ba2b2e4
|
|
BLAKE2b-256 checksum How to use checksums |
bbf26a3793d12d6fc6319357ebb0e4d1ecba39bc9786dfc60cfa05bee74244f9
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
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 Oct 6, 2026.
Transparency logRelease files / waterz-0.10.1-cp311-abi3-win_amd64.whl
| Download URL | waterz-0.10.1-cp311-abi3-win_amd64.whl |
|---|---|
| Size | 510.7 kB |
| Tags | CPython 3.11 Windows x86-64 abi3 |
|
SHA-256 checksum How to use checksums |
c95ad21bddb1dd5607f5aa0752832c704be491527deaefc77f6e4069f384851a
|
|
BLAKE2b-256 checksum How to use checksums |
01d4e3f7f2ef9d3c813292c322f182baddfdc1d933143f6a990695dec644c589
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
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 Oct 6, 2026.
Transparency logRelease files / waterz-0.10.1-cp311-abi3-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl
| Download URL | waterz-0.10.1-cp311-abi3-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl |
|---|---|
| Size | 466.2 kB |
| Tags | CPython 3.11 Linux glibc 2.24+ x86-64 Linux glibc 2.28+ x86-64 abi3 |
|
SHA-256 checksum How to use checksums |
5f696befbc48730f2a3b3052cccf32359eb519d468e6a8db336b12e07c3b63cf
|
|
BLAKE2b-256 checksum How to use checksums |
a7d41a9081314ef017ad762df7d39a3dae32984336f8caa43487ef9e1df92814
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
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 Oct 6, 2026.
Transparency logRelease files / waterz-0.10.1-cp311-abi3-manylinux_2_24_aarch64.manylinux_2_28_aarch64.whl
| Download URL | waterz-0.10.1-cp311-abi3-manylinux_2_24_aarch64.manylinux_2_28_aarch64.whl |
|---|---|
| Size | 440.2 kB |
| Tags | CPython 3.11 Linux glibc 2.24+ ARM64 Linux glibc 2.28+ ARM64 abi3 |
|
SHA-256 checksum How to use checksums |
1aa56db0db1e939ac215d3b92e6a496b99de8663a7628adf26fe9e8af08ff3f3
|
|
BLAKE2b-256 checksum How to use checksums |
e63ff663b079d52dd82c3394654cf212361aa5d21eb1d4fc8a470122a8567163
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
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 Oct 6, 2026.
Transparency logRelease files / waterz-0.10.1-cp311-abi3-macosx_11_0_arm64.whl
| Download URL | waterz-0.10.1-cp311-abi3-macosx_11_0_arm64.whl |
|---|---|
| Size | 415.9 kB |
| Tags | CPython 3.11 abi3 macOS 11.0+ ARM64 |
|
SHA-256 checksum How to use checksums |
b2f41adacd8189b575e3290db25f75805d5970c74a59333432da0dc88e2bdf15
|
|
BLAKE2b-256 checksum How to use checksums |
9014b68268920b1e2879025aedf3ef016fb2c228df948f147409fc44b57d3785
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
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 Oct 6, 2026.
Transparency logRelease files / waterz-0.10.1-cp311-abi3-macosx_10_9_x86_64.whl
| Download URL | waterz-0.10.1-cp311-abi3-macosx_10_9_x86_64.whl |
|---|---|
| Size | 427.9 kB |
| Tags | CPython 3.11 abi3 macOS 10.9+ x86-64 |
|
SHA-256 checksum How to use checksums |
3379d37fd835dba9b8f282fc677e0fd53ce5116e54c58ab4730cedba81cd8463
|
|
BLAKE2b-256 checksum How to use checksums |
c472895d352779d6c9bb4835418ace33cb1df5a0b36c02ee8677c0965df9f176
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
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 Oct 6, 2026.
Transparency log