Pottslab

Pottslab — Multilabel image segmentation via the Potts model

PyPI Python License: MIT MATLAB View Pottslab on File Exchange

Unsupervised multilabel image segmentation (colour, grayscale, multichannel) via the Potts model — also known as the piecewise-constant Mumford-Shah model or the ℓ⁰ gradient model. Solvers for 1-D denoising / step detection, 2-D image segmentation, and joint reconstruction-and-segmentation (deconvolution, Radon / MRI / PET).

Vector-valued segmentation

Featured in the MATLAB Central Pick of the Week (2017).

Quickstart

Python (Rust core)

pip install pottslab
import numpy as np
from pottslab import min_l2_potts, min_l2_potts_2d

# 1-D: denoise / step-detect a noisy piecewise-constant signal
y = np.array([0., 0.1, 0.05, 1.05, 0.95, 1.1, 0.0])
u = min_l2_potts(y, gamma=0.5)

# 2-D: segment a vector-valued image (H, W, C)
img = np.random.rand(64, 64, 3)
seg = min_l2_potts_2d(img, gamma=0.3)

The Python package wraps a Rust extension built with PyO3 and maturin; algorithm crates live under src/, demos under demos_python/. See README_PYTHON.md for the full Python API, inverse-Potts / sparsity / Tikhonov variants, and performance figures.

MATLAB

The original MATLAB / Java reference implementation is in this same repository:

  1. Run installPottslab.m to add the necessary folders to the MATLAB path.
  2. For best performance, increase Java heap space in the MATLAB preferences (MATLAB → General → Java Heap Memory).
  3. Run a demo from the Demos/ folder.

Troubleshooting

Standalone (command line, plain image segmentation only)

java -jar pottslab-standalone.jar input output.png gamma

where gamma is a positive real number, e.g. 0.1 (thanks to fxtentacle).

Application examples

Segmentation of vector-valued images

Vector-valued segmentation

Left: A natural image. Right: Result using the Potts model.

Texture segmentation

Texture segmentation using high-dimensional curvelet-based feature vectors.

Used as the segmentation method in:

Joint image reconstruction and segmentation

Phantom FBP Potts

Left: Shepp-Logan phantom. Centre: Filtered backprojection from 7 angular projections. Right: Joint reconstruction and segmentation using the Potts model from 7 angular projections.

Denoising / step detection of jump-sparse signals

Phantom

Top: Noisy signal. Bottom: Minimiser of the Potts functional (ground truth in red).

Used as the step-detection algorithm in:

Plugins for image-analysis GUIs

Parts of Pottslab can be used without MATLAB as pure Java plugins:

How to cite

If you use this software, please cite the relevant paper(s) below. GitHub’s “Cite this repository” button on the repo page reads the version and date-released fields from CITATION.cff and renders BibTeX/APA.

References

See also

Sibling projects from the same research program on variational methods for signal and image processing:

Related external projects:

License

Released under the MIT License. See LICENSE.


Project history

The Python / Rust port of this codebase was generated from the original MATLAB / Java reference by a Claude coding agent in 2026. The agent also found and fixed an off-by-one bug in the weighted-median computation inside IndexedLinkedHistogram (in both the new Rust port and the original Java). See PORTED_BY.md for full attribution and the porting plan.