Skip to main content
Pre-release

This release is a pre-release and may not be stable for production use.

waterz

License PyPI Python Version CI codecov

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>> for Q in 10, 15, 20, ..., 95 and B in true, false (and OneMinus<HistogramQuantileAffinity<RegionGraphType, Q, ScoreValue, 256>>, which is the same as B = 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.0rc1

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

Source distribution (sdist)

Source distribution for waterz 0.10.0rc1
File Size Uploaded
waterz-0.10.0rc1.tar.gz 39.6 kB Details

Built distributions (wheels)

Table of built distributions (wheels) for waterz 0.10.0rc1
File
waterz-0.10.0rc1-cp311-abi3-win_amd64.whl CPython 3.11 abi3 Windows x86-64 Details
waterz-0.10.0rc1-cp311-abi3-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl CPython 3.11 abi3 Linux glibc 2.28+ x86-64, Linux glibc 2.24+ x86-64 Details
waterz-0.10.0rc1-cp311-abi3-manylinux_2_24_aarch64.manylinux_2_28_aarch64.whl CPython 3.11 abi3 Linux glibc 2.24+ ARM64, Linux glibc 2.28+ ARM64 Details
waterz-0.10.0rc1-cp311-abi3-macosx_11_0_arm64.whl CPython 3.11 abi3 macOS 11.0+ ARM64 Details
waterz-0.10.0rc1-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.0rc1.tar.gz

Download URL waterz-0.10.0rc1.tar.gz
Size 39.6 kB
Tags Source
SHA-256 checksum
How to use checksums
f82a3f6e5723f709fe47d74e5529a7f017edf026f7b73117198c9dfcbad0e6ca
BLAKE2b-256 checksum
How to use checksums
d9c61840fa4085a9819a06e5fbd757f1cda8cad7f4b2df1477fd18bf1b62f4c9
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 1, 2026.

Transparency log

Release files / waterz-0.10.0rc1-cp311-abi3-win_amd64.whl

Download URL waterz-0.10.0rc1-cp311-abi3-win_amd64.whl
Size 508.2 kB
Tags CPython 3.11 Windows x86-64 abi3
SHA-256 checksum
How to use checksums
d4cffcf21b7ef1306fbabafcb071cf6b289dea65dc1048341ac2c15a2a2efea6
BLAKE2b-256 checksum
How to use checksums
eb787fadf9015ae565d8ed71cab6d15663c778d13c4468aef46c51f49593561a
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 1, 2026.

Transparency log

Release files / waterz-0.10.0rc1-cp311-abi3-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl

Download URL waterz-0.10.0rc1-cp311-abi3-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl
Size 463.7 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
510351f97be111308826cf6aadd65cc9bffd3917a62e5bde688382aced7325cd
BLAKE2b-256 checksum
How to use checksums
84765075aa7cfb48154f9444ce131552e0f6d6677e81de7dc1d46a3589d08e63
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 1, 2026.

Transparency log

Release files / waterz-0.10.0rc1-cp311-abi3-manylinux_2_24_aarch64.manylinux_2_28_aarch64.whl

Download URL waterz-0.10.0rc1-cp311-abi3-manylinux_2_24_aarch64.manylinux_2_28_aarch64.whl
Size 439.6 kB
Tags CPython 3.11 Linux glibc 2.24+ ARM64 Linux glibc 2.28+ ARM64 abi3
SHA-256 checksum
How to use checksums
ff883968418113f1980dc1f26ef07fb81bf03545c2bf1dab7fde6d0b226690be
BLAKE2b-256 checksum
How to use checksums
d03d3d819fbe4508952f442b4c595f6b484235a1cd4168c3d44ec7af97eca69e
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 1, 2026.

Transparency log

Release files / waterz-0.10.0rc1-cp311-abi3-macosx_11_0_arm64.whl

Download URL waterz-0.10.0rc1-cp311-abi3-macosx_11_0_arm64.whl
Size 407.6 kB
Tags CPython 3.11 abi3 macOS 11.0+ ARM64
SHA-256 checksum
How to use checksums
8b5413f4828f41e648af6aaf9226d773c6b0109579f7a3f2f852e8754f235f96
BLAKE2b-256 checksum
How to use checksums
845f6e09b4fcfeef699ef55d7f68688c20497d6b3d190a92c88f3a7395d88a0d
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 1, 2026.

Transparency log

Release files / waterz-0.10.0rc1-cp311-abi3-macosx_10_9_x86_64.whl

Download URL waterz-0.10.0rc1-cp311-abi3-macosx_10_9_x86_64.whl
Size 421.0 kB
Tags CPython 3.11 abi3 macOS 10.9+ x86-64
SHA-256 checksum
How to use checksums
bdc6a3acf2d441ce3c85d874d683ef9d03e790c3f5cba0d1781af4ccc9a64ff3
BLAKE2b-256 checksum
How to use checksums
956e702922559f7c2e52eb27367cf6f5a23fccfa8c68a0d7a200dff3c9d450fc
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 1, 2026.

Transparency log

Release history Release notifications | RSS feed

This release

0.10.0rc1 This release

6 release files

0.9.4

18 release files

0.9.2

17 release files

0.9.1

16 release files

0.9.0

16 release files

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