Pottslab is a Matlab/Java toolbox for the reconstruction of jump-sparse signals and images using the Potts model (also known as "piecewise constant Mumford-Shah model" or "l0 gradient model"). Applications include denoising of piecewise constant signals, step detection and segmentation of multichannel images.
-- See also the Pick of the Week on --
A Python package (pottslab) with a Rust performance core was generated from
this repository by Claude Sonnet (Anthropic's
AI coding agent) in 2026. It exposes the same algorithms through a clean,
type-annotated Python API backed by compiled Rust (via PyO3) instead of the
original Java JAR.
What the agent did:
- Ported all time-critical algorithms from Java to Rust (
src/):L2Potts.java→l2potts.rs,IndexedLinkedHistogram.java→l1potts.rs,PLProcessor.java→processor.rs,JavaTools.javaADMM →admm.rs - Ported all MATLAB helper modules to Python (
pottslab/): 1D/2D Potts solvers, inverse Potts, Tikhonov regularisation, sparsity, utilities - Found and fixed an off-by-one bug in the weighted-median computation inside
IndexedLinkedHistogram(both in the new Rust port and in the originalJava/src/pottslab/IndexedLinkedHistogram.java). The bug caused the L1-Potts DP to occasionally prefer a suboptimal multi-jump solution over the correct constant-segment solution on odd-length inputs. - Eliminated two O(n²) allocation hot-spots in the Rust L1-Potts solver (arena
cloning and per-iteration
Vecallocation), recovering the performance advantage over the JVM at typical signal lengths. - Wrote 418 tests covering correctness, brute-force cross-validation, numerical precision, properties, edge cases, and input-validation guards.
- Built a standalone Java benchmark harness (
Java/src/pottslab/Benchmark.java) and Python benchmark script (benchmark.py) for direct Java-vs-Rust comparison.
See README_PYTHON.md for installation, API reference, and
performance figures. See PORTED_BY.md for full attribution.
- Supports segmentation of vector-valued images (e.g. multispectral images, feature images)
- Linear complexity in number of color channels
- Label-free: No label discretization required
Left: A natural image; Right: Result using Potts model
Texture segmentation using highdimensional curvelet-based feature vectors
Used as segmentation method in
- A. Breger et al., Supervised learning and dimension reduction techniques for quantification of retinal fluid in optical coherence tomography images, Eye (2017).
- Applicable to many imaging operators, e.g. convolution, Radon transform, MRI, PET, MPI: only implementation of proximal mapping reuqired - Supports vector-valued data - Label-free: Labels need NOT be chosen a-priori
Left: Shepp-Logan phantom; Center: Filtered backprojection from 7 angular projections; Right: Joint reconstruction and segmentation using the Potts model from 7 angular projections
- L1 Potts model is robust to noise and to moderately blurred data
- Fast and exact solver for L1 Potts model
- Approximative strategies for severely blurred data
Top: Noisy signal; Bottom: Minimizer of Potts functional (ground truth in red)
Used as step detection algorithm in
- A. Nord et al., Catch bond drives stator mechanosensitivity in the bacterial flagellar motor, Proceedings of the National Academy of Sciences, 2017
- A. Szorkovszky et al., Assortative interactions revealed by sorting of animal groups, Animal Behaviour, 2018
- Call "java -jar pottslab-standalone.jar input output.png gamma" where gamma is a positive real number, e.g. 0.1 (thanks to fxtentacle)
- Run the script "installPottslab.m", it should set all necessary paths
- For best performance, increase Java heap space in the Matlab preferences (MATLAB - General - Java heap memory)
- Run a demo from the Demos folder
-
Problem: OutOfMemoryException
-
Solution: Increase Java heap space in the Matlab preferences (MATLAB - General - Java heap memory)
-
Problem: Undefined variable "pottslab" or class "pottslab.JavaTools.minL2Potts"
-
Solution:
- Run setPLJavaPath.m
- Maybe you need to install Java 1.7 (see e.g. http://undocumentedmatlab.com/blog/using-java-7-in-matlab-r2013a-and-earlier)
Parts of Pottslab can be used without Matlab as pure Java plugins
- Icy plugin - an interactive image segmentation plugin based on Pottslab (written by Vasileios Angelopoulos)
- ImageJ plugin - an ImageJ frontend for Pottslab (written by Michael Kaul)
- M. Storath, A. Weinmann, J. Frikel, M. Unser. "Joint image reconstruction and segmentation using the Potts model" Inverse Problems, 2015
- A. Weinmann, M. Storath. "Iterative Potts and Blake-Zisserman minimization for the recovery of functions with discontinuities from indirect measurements." Proceedings of The Royal Society A, 471(2176), 2015
- A. Weinmann, M. Storath, L. Demaret. "The L1-Potts functional for robust jump-sparse reconstruction" SIAM Journal on Numerical Analysis, 2015
- M. Storath, A. Weinmann. "Fast partitioning of vector-valued images" SIAM Journal on Imaging Sciences, 2014
- M. Storath, A. Weinmann, L. Demaret. "Jump-sparse and sparse recovery using Potts functionals" IEEE Transactions on Signal Processing, 2014





