Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

mstorath/Pottslab

Open more actions menu

Repository files navigation

Pottslab

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 View Pottslab - Multilabel segmentation of vectorial data on File Exchange --


Python/Rust port — created by a Claude coding agent

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.javal2potts.rs, IndexedLinkedHistogram.javal1potts.rs, PLProcessor.javaprocessor.rs, JavaTools.java ADMM → 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 original Java/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 Vec allocation), 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.


Application examples

Segmentation of vector-valued images

  • 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

Vector-valued segmentation

Left: A natural image; Right: Result using Potts model

Vector-valued segmentation

Texture segmentation using highdimensional curvelet-based feature vectors

Used as segmentation method in

Joint image reconstruction and segmentation

  • 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

Phantom Phantom Phantom

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

Denoising of jump-sparse/piecewise-constant signals, or step detection/changepoint detection

  • 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

Phantom

Top: Noisy signal; Bottom: Minimizer of Potts functional (ground truth in red)

Used as step detection algorithm in

Usage Instructions

Standalone usage from command line (only image plain image segmentation supported)

  • Call "java -jar pottslab-standalone.jar input output.png gamma" where gamma is a positive real number, e.g. 0.1 (thanks to fxtentacle)

Installation for Matlab (all features usable)

Quickstart:

  • 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

Troubleshooting:

Plugins for Image Analysis GUIs

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)

References

  • 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

See also

About

Unsupervised multilabel image segmentation (color/gray/multichannel) based on the Potts model (aka piecewise constant Mumford-Shah model)

Topics

Resources

License

MIT, MIT licenses found

Licenses found

MIT
LICENSE
MIT
License.txt

Stars

Watchers

Forks

Packages

 
 
 

Contributors

Morty Proxy This is a proxified and sanitized view of the page, visit original site.