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

Featured in the MATLAB Central Pick of the Week (2017).
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.
The original MATLAB / Java reference implementation is in this same repository:
installPottslab.m to add the necessary folders to the MATLAB path.Demos/ folder.setPLJavaPath.m. You may also need to install Java 1.7 (see e.g. undocumentedmatlab.com).java -jar pottslab-standalone.jar input output.png gamma
where gamma is a positive real number, e.g. 0.1 (thanks to fxtentacle).

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

Texture segmentation using high-dimensional curvelet-based feature vectors.
Used as the segmentation method in:

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

Top: Noisy signal. Bottom: Minimiser of the Potts functional (ground truth in red).
Used as the step-detection algorithm in:
Parts of Pottslab can be used without MATLAB as pure Java plugins:
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.
Sibling projects from the same research program on variational methods for signal and image processing:
Related external projects:
Released under the MIT License. See LICENSE.
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.