### Total Variation Prior

In another post I computed the negative-loglikelihood of an image given current dipole fields $g$ with a quadratic prior probability on $g$. The quadratic priors penalize sharp edges too much, causing the reconstruction to suffer near line currents. To remedy this I switch to a total variation (TV) regularization, which imposes sparse gradients on the image:

This prior favors images with constant patches, where only the boundaries contribute to $TV(g)$ and reduce the probability. Since we’re mostly interested in the currents, which are the derivatives of $g$, we will instead impose a sparsity of the second derivatives or equivalently a sparsity of the second derivatives of $g$:

for horizontal ($x$) derivatives $D_h$ and vertical ($y$) derivatives $D_v$. Then, as in Gradients of NLL we define