Skip to main content

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

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.0
File Size Uploaded
waterz-0.10.0.tar.gz 41.6 kB Details

Built distributions (wheels)

Table of built distributions (wheels) for waterz 0.10.0
File
waterz-0.10.0-cp311-abi3-win_amd64.whl CPython 3.11 abi3 Windows x86-64 Details
waterz-0.10.0-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.0-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.0-cp311-abi3-macosx_11_0_arm64.whl CPython 3.11 abi3 macOS 11.0+ ARM64 Details
waterz-0.10.0-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.0.tar.gz

Download URL waterz-0.10.0.tar.gz
Size 41.6 kB
Tags Source
SHA-256 checksum
How to use checksums
f76551443c30b7399280a6294d142c4f6f2e30c57cbf5539cd1d693b08663e97
BLAKE2b-256 checksum
How to use checksums
a8e22e49e0b9c3451995d5684da55310bb09e4d130b5787587c60a97e5a52501
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 3, 2026.

Transparency log

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

Download URL waterz-0.10.0-cp311-abi3-win_amd64.whl
Size 510.8 kB
Tags CPython 3.11 Windows x86-64 abi3
SHA-256 checksum
How to use checksums
9ce50bd18c095cc0a46b93be8a45e6c0a64d18bab2891767151de99260a41c3a
BLAKE2b-256 checksum
How to use checksums
fce899f6028b2557ffe4dbd797316789bf0889f9524893bb4a47a097a2557cf2
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 3, 2026.

Transparency log

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

Download URL waterz-0.10.0-cp311-abi3-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl
Size 467.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
0ae0c95ed0963bceb8d13768fc44a63f7eb5d54ab09d63de7cbcf64057b7039f
BLAKE2b-256 checksum
How to use checksums
91a32a76bf20fbfc96e711721a7fd908c8f686a41d6bce67c137191bee46d45d
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 3, 2026.

Transparency log

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

Download URL waterz-0.10.0-cp311-abi3-manylinux_2_24_aarch64.manylinux_2_28_aarch64.whl
Size 442.0 kB
Tags CPython 3.11 Linux glibc 2.24+ ARM64 Linux glibc 2.28+ ARM64 abi3
SHA-256 checksum
How to use checksums
804ec97857f2640274413979e5d5767e12abeb576ab25450abfa3124731ee8eb
BLAKE2b-256 checksum
How to use checksums
e1085c70b8642f81abc4d55e5e8f159d9c005009ae2315088a5803e24a7976dc
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 3, 2026.

Transparency log

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

Download URL waterz-0.10.0-cp311-abi3-macosx_11_0_arm64.whl
Size 413.6 kB
Tags CPython 3.11 abi3 macOS 11.0+ ARM64
SHA-256 checksum
How to use checksums
a7b263f8379a34d5859a7b2f855a84571fabf9a0822384b822939ace0134f12e
BLAKE2b-256 checksum
How to use checksums
c0564b03bff295f75d05ee0e72ccfadc1d476abe076957892677aa01db939f8e
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 3, 2026.

Transparency log

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

Download URL waterz-0.10.0-cp311-abi3-macosx_10_9_x86_64.whl
Size 423.6 kB
Tags CPython 3.11 abi3 macOS 10.9+ x86-64
SHA-256 checksum
How to use checksums
a429b6bc78bcc670c78598340bf04f29f3fb37a9abca0eda1a1fb80eb153cdfd
BLAKE2b-256 checksum
How to use checksums
f53260484acdc1513b2580ac181260a5538895960f64f87be249032e9dba94af
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 3, 2026.

Transparency log

Release history Release notifications | RSS feed

This release

0.10.0 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