mixle.ppl.priors module

Edge-preserving and discrete-composition priors for latent fields (phase 4).

The Gaussian-Markov / GP field prior is smooth – it blurs sharp material boundaries and cannot express a field that takes a few discrete values (a composition of distinct materials). These priors fix that, and they plug into the field surface as data-less proxies: a prior is a proxy whose log-likelihood is the negative penalty, so joint([Gaussian(...), TotalVariation(over=field, shape=...)]) can include it directly.

  • TotalVariation() – a smoothed total-variation penalty on the field’s gradient, which preserves sharp edges where the smooth prior would round them (the standard regularizer for piecewise-constant images / sharp inclusions).

  • Potts() – a multi-well penalty pulling each node toward one of a few given levels, encoding a discrete material composition (a continuous relaxation of the Potts model).

Both are most useful with how='map' (the edge-preserving / discrete reconstruction is the point; the posterior is genuinely non-Gaussian, so Laplace/Gauss-Newton only approximate it around the mode).

TotalVariation(over, shape, *, weight=1.0, eps=1e-3)[source]

A smoothed total-variation prior on the field over a structured shape grid: weight * sum over neighbour pairs sqrt((f_a - f_b)^2 + eps^2). Edge-preserving (it does not penalize a jump as harshly as the squared GMRF prior). Returns the (field, proxy) pair for joint().

Parameters:
Return type:

tuple

Potts(over, levels, *, weight=1.0)[source]

A discrete-composition prior: weight * sum_i prod_k (f_i - level_k)^2 – a multi-well potential whose minima are the given levels, pulling the field toward a few discrete material values (a smooth relaxation of the Potts model). Combine with TotalVariation() for piecewise-constant regions. Returns the (field, proxy) pair for joint().

Parameters:

weight (float)

Return type:

tuple