Skip to main content

Mumford-Shah edge-preserving image restoration — Python/Rust port of MATLAB/Java MumfordShah2D (Hohm, Storath & Weinmann)

Project description

mumfordshah2d (Python / Rust)

Python / Rust port of the MATLAB / Java MumfordShah2D library. Edge-preserving image restoration via the piecewise-smooth Mumford-Shah model of Hohm, Storath, and Weinmann (Inverse Problems 31(11), 2015).

Status: 0.5.2 — Phase 4 (beta). The 4-connected (anisotropic) 2-D Mumford-Shah ADMM driver is ported and verified at 1e-9 element-wise against MATLAB. 8-connected and ρ-coupled variants remain on the roadmap. See PORTED_BY.md for the phasing plan.

Installation

From PyPI:

pip install mumfordshah2d

From source (requires Rust + maturin):

pip install maturin
maturin develop --release

Or as a regular editable install (also builds the Rust core):

pip install -e .

Quick check

import mumfordshah2d
print(mumfordshah2d.__version__)             # 0.1.0
print(mumfordshah2d.__original_authors__)    # Kilian Hohm, Martin Storath, Andreas Weinmann

import numpy as np
from mumfordshah2d import gauss_l2_mum_solve

# L2-Mumford-Shah within-segment smoothing on a noisy step:
y = np.array([0.0, 0.1, -0.05, 1.05, 0.95, 1.1])
mu = gauss_l2_mum_solve(y, alpha=2.0)
print(mu)

What's currently exported

# Utilities
soft_threshold, hard_threshold, expand_weights, rotate90, psnr

# Prox handles for the ADMM data-fidelity term
make_prox_l2w, make_prox_l1w, make_prox_l0w, make_prox_inpaint

# Phase 1 Rust primitive (exposed for testing)
gauss_l2_mum_solve

# Metadata
__version__, __original_authors__, __ported_by__

The full public API (min_l2_l2_mumford_shah_2d etc.) ships in Phase 4. Until then, use the original MATLAB code in mumfordShah2D.m for end-to-end restoration — that path is unchanged by this port.

Array conventions

  • Python API: grayscale arrays are (rows, cols); colour/multichannel arrays are (rows, cols, channels) (numpy / imageio convention).
  • Internal Rust core: (channels, rows, cols) (Java / MATLAB convention).
  • A single conversion happens at the PyO3 boundary in src/lib.rs.

Verification approach (Phases 2–5)

The Java .class files in Java/bin/mumfordShah/ are kept on disk as a reference oracle. From Phase 2 onwards, every Rust algorithm is fuzzed against the Java implementation via a small TestHarness.java subprocess shim, ensuring bit-equivalent (≤ 1e-12) results on hundreds of random inputs.

License

MIT, copyright Kilian Hohm, Martin Storath, Andreas Weinmann (original) and the Claude Sonnet coding agent contribution (Anthropic, 2026, port). See LICENSE and PORTED_BY.md.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

mumfordshah2d-0.5.2.tar.gz (15.1 MB view details)

Uploaded Source

Built Distributions

If you're not sure about the file name format, learn more about wheel file names.

mumfordshah2d-0.5.2-cp39-abi3-win_amd64.whl (251.5 kB view details)

Uploaded CPython 3.9+Windows x86-64

mumfordshah2d-0.5.2-cp39-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (355.5 kB view details)

Uploaded CPython 3.9+manylinux: glibc 2.17+ x86-64

mumfordshah2d-0.5.2-cp39-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (329.9 kB view details)

Uploaded CPython 3.9+manylinux: glibc 2.17+ ARM64

mumfordshah2d-0.5.2-cp39-abi3-macosx_11_0_arm64.whl (334.4 kB view details)

Uploaded CPython 3.9+macOS 11.0+ ARM64

mumfordshah2d-0.5.2-cp39-abi3-macosx_10_12_x86_64.whl (346.6 kB view details)

Uploaded CPython 3.9+macOS 10.12+ x86-64

File details

Details for the file mumfordshah2d-0.5.2.tar.gz.

File metadata

  • Download URL: mumfordshah2d-0.5.2.tar.gz
  • Upload date:
  • Size: 15.1 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for mumfordshah2d-0.5.2.tar.gz
Algorithm Hash digest
SHA256 14dec1334a0f0565353f683063e2d651e69da2023170e767353af6967d0f19c0
MD5 744719c9139f6a42b80fb49e80ca4def
BLAKE2b-256 4d6631e7acbc9dc4d37a9b9fcdae7b94316775a2f9a48e36f48f97b0c8d64ee7

See more details on using hashes here.

Provenance

The following attestation bundles were made for mumfordshah2d-0.5.2.tar.gz:

Publisher: release.yml on mstorath/MumfordShah2D

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file mumfordshah2d-0.5.2-cp39-abi3-win_amd64.whl.

File metadata

  • Download URL: mumfordshah2d-0.5.2-cp39-abi3-win_amd64.whl
  • Upload date:
  • Size: 251.5 kB
  • Tags: CPython 3.9+, Windows x86-64
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for mumfordshah2d-0.5.2-cp39-abi3-win_amd64.whl
Algorithm Hash digest
SHA256 925b22fac1f03f66550275f1a9f87ad63f6df9a5db691a41429248baef813e21
MD5 1c239ad3c7536136873d783c52716002
BLAKE2b-256 91405b3e3839c966b2d7e901394fe0cd5ce9ae1b2ba6c984e197d96fe4325a0d

See more details on using hashes here.

Provenance

The following attestation bundles were made for mumfordshah2d-0.5.2-cp39-abi3-win_amd64.whl:

Publisher: release.yml on mstorath/MumfordShah2D

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file mumfordshah2d-0.5.2-cp39-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for mumfordshah2d-0.5.2-cp39-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 7a7ad4aad561be5e1c3486cdb664f472b762784272f1c9d340a6c67a1c4575f0
MD5 d6564fc0bbcb3e7eaebbc39deff5a9b3
BLAKE2b-256 5fbf2a11b83561cc8c2d61ac22d80bccaea04e4b91c5e2591a0db1e395543e4e

See more details on using hashes here.

Provenance

The following attestation bundles were made for mumfordshah2d-0.5.2-cp39-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl:

Publisher: release.yml on mstorath/MumfordShah2D

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file mumfordshah2d-0.5.2-cp39-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl.

File metadata

File hashes

Hashes for mumfordshah2d-0.5.2-cp39-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 03d551edd816c151ffdf2719d8aa350c0486c22aec60a719b6e4c178443553f5
MD5 0d1861dca4776c5b2c5b306f0913fad2
BLAKE2b-256 160878557a095135bdfcec4f1ad55f81c40247b7ead2095a0eef0ca10414a0cd

See more details on using hashes here.

Provenance

The following attestation bundles were made for mumfordshah2d-0.5.2-cp39-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl:

Publisher: release.yml on mstorath/MumfordShah2D

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file mumfordshah2d-0.5.2-cp39-abi3-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for mumfordshah2d-0.5.2-cp39-abi3-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 b74d3c056d5af3db1c959aa084a44d9810338e33d274dc4de0c6fb284a2c2373
MD5 cfaf06a62e61f84a50684a2820e33e93
BLAKE2b-256 ce5d5ede830e37e778a9f3de27187b8ac14cac4c11e3620a5059ed7a09a0fe55

See more details on using hashes here.

Provenance

The following attestation bundles were made for mumfordshah2d-0.5.2-cp39-abi3-macosx_11_0_arm64.whl:

Publisher: release.yml on mstorath/MumfordShah2D

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file mumfordshah2d-0.5.2-cp39-abi3-macosx_10_12_x86_64.whl.

File metadata

File hashes

Hashes for mumfordshah2d-0.5.2-cp39-abi3-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 0dbb1f2103674b9b8e4b8eecd5d04c126f39e636a3c43eace62ebce49253ac06
MD5 b8f3195ea53f2a8d3824d4683829ceed
BLAKE2b-256 82f2e50bbf1fc6dedfda65f7c9f21eedb750c7f51d144db7d48417b0f18ffbbc

See more details on using hashes here.

Provenance

The following attestation bundles were made for mumfordshah2d-0.5.2-cp39-abi3-macosx_10_12_x86_64.whl:

Publisher: release.yml on mstorath/MumfordShah2D

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page