Skip to article frontmatterSkip to article content
Site not loading correctly?

This may be due to an incorrect BASE_URL configuration. See the MyST Documentation for reference.

8. Variational Priors and Regularization

CNRS & DMA, École Normale Supérieure

Chapter PDF · Complete book

Variational methods reconstruct images by balancing agreement with measured data against a penalty describing expected image structure. The choice of penalty controls the tradeoff between noise removal and preservation of sharp edges. Starting from Sobolev and total variation energies, we develop their discrete operators, derive the associated diffusion flows, and compare stopping a flow early with minimizing an energy that includes a data fidelity term.

8.1 Sobolev and Total Variation Priors

The simplest priors integrate local differential quantities over the image domain. They measure smoothness through seminorms on function spaces. We study two widely used examples: the Sobolev and total variation priors.

8.1.1 Continuous Priors

In this section we define priors for functions fL2([0,1]2)f \in L^2([0,1]^2) on a continuous domain. Section 8.1.2 develops their counterparts for discrete images fRNf \in \mathbb{R}^N.

Sobolev prior.

A prior energy assigns small values to images in the target class Θ\Theta and larger values, possibly ++\infty, to images that depart from that model. The smoothness classes described in Section 5.2.1 motivate Sobolev priors. The simplest such energy is

JSob(f)=12fH12=12 ⁣f(x) ⁣2dx,(8.1)J_{\text{Sob}}(f) = \frac{1}{2}|f|_{H^1}^2 = \frac{1}{2} \int |\!| \nabla f(x) |\!|^2 \mathrm{d}x, \tag{8.1}

where f\nabla f is the distributional gradient and the integral is over [0,1]2[0,1]^2. The energy is one half of the squared H1H^1 seminorm and vanishes on constant functions. We set it to ++\infty when the gradient is not square integrable.

Total variation prior.

To accommodate discontinuities in images, we use the total variation energy introduced in Section 5.2.3. Rudin, Osher, and Fatemi introduced its use in image denoising [28].

The total variation of a smooth image ff is defined as

JTV(f)= ⁣f ⁣TV= ⁣xf ⁣dx.(8.2)J_{\text{TV}}(f) = |\!| f |\!|_{\text{TV}} = \int |\!| \nabla_x f |\!| \mathrm{d}x. \tag{8.2}

This energy extends to functions of bounded variation fBV([0,1]2)f \in \text{BV}([0,1]^2), which may be discontinuous. This class includes indicator functions f=1Ωf=1_{\Omega} of sets Ω\Omega with finite perimeter Ω|\partial \Omega|.

The total variation seminorm can also be computed using the coarea formula (5.12), which shows in particular that  ⁣1Ω ⁣TV=Ω|\!| 1_{\Omega} |\!|_{\text{TV}} = |\partial \Omega|.

8.1.2 Discrete Priors

An acquisition device discretizes a continuous-domain image fL2([0,1]2)f \in L^2([0,1]^2) into a pixel array fRNf \in \mathbb{R}^N. To process these data, we need priors defined on finite-dimensional image spaces.

Discrete gradient.

Discrete Sobolev and total variation priors use finite-difference approximations to derivatives. For example, the forward differences are

δ1fn1,n2=fn1+1,n2fn1,n2δ2fn1,n2=fn1,n2+1fn1,n2,\begin{aligned} \delta_1 f_{n_1,n_2} &= f_{n_1+1,n_2}- f_{n_1,n_2} \\ \delta_2 f_{n_1,n_2} &= f_{n_1,n_2+1}- f_{n_1,n_2}, \end{aligned}

where the image has n×nn\times n pixels and N=n2N=n^2. Higher-order schemes give more accurate approximations for smooth functions. Boundary conditions require care. For simplicity, we use periodic boundary conditions, computing the indices ni+1n_i+1 modulo nn. Symmetric boundary conditions can also be used to avoid boundary artifacts.

With the grid-spacing factor absorbed into the energy scaling, the discrete gradient at each pixel is

fn=(δ1fn,δ2fn)R2\nabla f_n = ( \delta_1 f_n,\delta_2 f_n ) \in \mathbb{R}^{2}

and the gradient operator maps images to vector fields:

:RNRN×2.\nabla : \mathbb{R}^N \longrightarrow \mathbb{R}^{N \times 2}.

Figure 8.1 shows discrete gradient vectors approximating the local direction of steepest intensity increase. Figure 8.2 displays the signed gradient components and their Euclidean magnitude. A shared nonlinear display curve enhances weak red and blue components without changing the numerical gradient. Large magnitudes indicate rapid intensity variations, typically at edges or in textured regions.

Figure 8.1. Discrete gradient vectors.

Discrete divergence.

One can also use backward differences,

δ~1fn1,n2=fn1,n2fn11,n2δ~2fn1,n2=fn1,n2fn1,n21.\begin{aligned} \tilde\delta_1 f_{n_1,n_2} &= f_{n_1,n_2}- f_{n_1-1,n_2} \\ \tilde\delta_2 f_{n_1,n_2} &= f_{n_1,n_2}- f_{n_1,n_2-1}. \end{aligned}

The adjoint relation between backward and forward differences is

δi=δ~i,\delta_i^* = -\tilde \delta_i,

which means that

f,gRN,δif,g=f,δ~ig,\forall \,f,g \in \mathbb{R}^N, \quad \langle \delta_i f,\,g\rangle = - \langle f,\,\tilde \delta_i g\rangle,

This is the discrete counterpart of integration by parts,

01fg=01fg\int_0^1 f' g = - \int_0^1 f g'

for smooth periodic functions on [0,1][0,1].

We define the discrete divergence using backward differences:

div(v)n=δ~1v1,n+δ~2v2,n,\mathop{\mathrm{div}}(v)_n = \tilde \delta_1 v_{1,n} + \tilde \delta_2 v_{2,n},

This operator maps vector fields to images:

div:RN×2RN.\mathop{\mathrm{div}}: \mathbb{R}^{N \times 2} \longrightarrow \mathbb{R}^{N}.

It is the negative adjoint of the gradient:

div=\mathop{\mathrm{div}}= - \nabla^*

which means that

fRN,  vRN×2,f,vRN×2=f,div(v)RN\forall \,f \in \mathbb{R}^N, \; \forall \,v \in \mathbb{R}^{N \times 2}, \quad \langle \nabla f,\,v\rangle_{\mathbb{R}^{N \times 2}} = -\langle f,\,\mathop{\mathrm{div}}(v)\rangle_{\mathbb{R}^N}

This identity is a discrete version of the divergence theorem.

Figure 8.2. Discrete gradient of the flower image. Red and blue encode the signed horizontal and vertical components with enhanced display contrast; neutral gray represents zero. The last panel shows the Euclidean gradient magnitude.

Discrete Laplacian.

The Laplacian is the divergence of the gradient:

Δf=div(f),\Delta f= \mathop{\mathrm{div}}( \nabla f ),

This operator is negative semidefinite because Δ=\Delta=-\nabla^*\nabla.

With the discrete gradient and divergence defined above, the Laplacian is the local high-pass filter

Δfn=pV4(n)fp4fn,(8.3)\Delta f_n = \sum_{ p \in V_4(n) } f_p - 4 f_n, \tag{8.3}

which, after scaling by the grid spacing, approximates the continuous Laplacian:

2fx12(x)+2fx22(x)n2Δfkforx=k/n.\frac{ \partial^2 f}{\partial x_1^2} (x) + \frac{ \partial^2 f}{\partial x_2^2} (x) \approx n^2 \Delta f_{k} \quad \text{for} \quad x = k/n.

Laplacian operators thus act as filters. With the Fourier convention f^(ω)=f(x)eix,ωdx\hat f(\omega)=\int f(x)e^{-\mathrm{i}\langle x,\omega\rangle}\,\mathrm{d}x, the continuous Laplacian is diagonal in the Fourier domain:

g=Δfg^(ω)= ⁣ω ⁣2f^(ω)g = \Delta f \quad\Longrightarrow\quad\hat g(\omega) = -|\!| \omega |\!|^2 \hat f(\omega)

while the discrete Laplacian (8.3) has Fourier representation

g=Δfg^ω=ρω2f^ωwhereρω2=4sin(πnω1)2+4sin(πnω2)2.(8.4)g = \Delta f \quad\Longrightarrow\quad\hat g_\omega= -\rho_\omega^2 \hat f_\omega \quad \text{where} \quad \rho_\omega^2 = 4\sin\left( \frac{\pi}{n}\omega_1 \right)^2 + 4\sin\left( \frac{\pi}{n}\omega_2 \right)^2. \tag{8.4}

Discrete energies.

The discrete Sobolev energy is one half of the squared 2\ell^2 norm of the gradient field:

JSob(f)=12n((δ1fn)2+(δ2fn)2)=12 ⁣f ⁣2.(8.5)J_{\text{Sob}}(f) = \frac{1}{2} \sum_n \big( ( \delta_1 f_n )^2 + ( \delta_2 f_n )^2 \big) = \frac{1}{2} |\!| \nabla f |\!|^2. \tag{8.5}

The isotropic discrete TV energy instead sums the Euclidean magnitudes of the gradient vectors:

JTV(f)=n(δ1fn)2+(δ2fn)2= ⁣f ⁣1(8.6)J_{\text{TV}}(f) = \sum_n \sqrt{ ( \delta_1 f_n )^2 + ( \delta_2 f_n )^2 } = |\!| \nabla f |\!|_{1} \tag{8.6}

Here the notation  ⁣v ⁣1|\!| v |\!|_{1} for a vector field vRN×2v \in \mathbb{R}^{N \times 2} means

 ⁣v ⁣1=n ⁣vn ⁣(8.7)|\!| v |\!|_{1} = \sum_n |\!| v_n |\!| \tag{8.7}

where vnR2v_n \in \mathbb{R}^2.

8.2 PDE and Energy Minimization

Minimizing a smooth prior by gradient descent produces an image-smoothing flow.

8.2.1 General Flows

The gradient of a differentiable prior J:RNRJ : \mathbb{R}^N \rightarrow \mathbb{R} is the vector gradJ(f)\mathop{\mathrm{grad}}J(f) that describes its local first-order variation:

J(f+ε)=J(f)+ε,gradJ(f)+o( ⁣ε ⁣).J(f+\varepsilon) = J(f) + \langle \varepsilon,\,\mathop{\mathrm{grad}}J(f)\rangle + o(|\!| \varepsilon |\!|).

Gradient descent seeks to decrease a smooth discrete energy by iterating

f(k+1)=f(k)τgradJ(f(k)),(8.8)f^{(k+1)} = f^{(k)} - \tau \mathop{\mathrm{grad}}J(f^{(k)}), \tag{8.8}

where the step size τ\tau is chosen to ensure descent. The quadratic and smoothed TV energies below admit explicit sufficient bounds on τ\tau.

To pass to continuous time, associate iteration kk with time t=kτt=k\tau and let τ\tau tend to zero. The limiting flow

t>0ftRNt > 0 \longmapsto f_t \in \mathbb{R}^N

satisfies the following differential equation, an ODE for a finite-dimensional image and a PDE when space is continuous:

ftt=gradJ(ft)andf0=f.(8.9)\frac{ \partial f_t}{\partial t} = - \mathop{\mathrm{grad}}J(f_t) \quad \text{and} \quad f_0 = f. \tag{8.9}

Gradient descent is an explicit time discretization of this differential equation at times tk=kτt_k = k \tau.

Figure 8.3. Heat flow (top) and TV flow (bottom): images ftf_t at increasing times tt.

8.2.2 Heat Flow

Heat flow results from applying (8.9) to the Sobolev energy JSob(f)J_{\text{Sob}}(f), defined in (8.1) for functions and in (8.5) for discrete images.

Expanding the quadratic energy gives

J(f+ε)=12 ⁣f+ε ⁣2=J(f)Δf,ε+12 ⁣ε ⁣2,J(f+\varepsilon) = \frac{1}{2}|\!| \nabla f+\nabla \varepsilon |\!|^2 = J(f) - \langle \Delta f,\,\varepsilon\rangle + \frac{1}{2}|\!| \nabla\varepsilon |\!|^2,

so that

gradJSob(f)=Δf.\mathop{\mathrm{grad}}J_{\text{Sob}}(f) = -\Delta f.

Figure 8.4, left, shows an image Laplacian. Its magnitude is typically large near edges, with either sign.

The heat flow is thus

ftt(x)=(gradJ(ft))(x)=Δft(x)andf0=f.(8.10)\frac{ \partial f_t}{\partial t} (x) = - (\mathop{\mathrm{grad}}J(f_t))(x) = \Delta f_t(x) \quad \text{and} \quad f_0 = f. \tag{8.10}

Figure 8.4. Discrete Laplacian (left) and negative discrete TV gradient (right).

Continuous in space.

For continuous images on the unbounded domain R2\mathbb{R}^2, the PDE (8.10) has an explicit solution: convolution with a Gaussian kernel whose variance grows with time

ft=fhtwhereht(x)=14πte ⁣x ⁣24t.(8.11)f_t = f \star h_t \quad \text{where} \quad h_t(x) = \frac{1}{4 \pi t} e^{-\frac{|\!| x |\!|^2}{4t}}. \tag{8.11}

Convolution with this widening kernel progressively smooths the image.

Discrete in space.

The gradient flow of the discrete Sobolev energy (8.5) is

fn,tt=(gradJ(ft))n=(Δft)n.\frac{ \partial f_{n,t}}{\partial t} = - (\mathop{\mathrm{grad}}J(f_t))_n = (\Delta f_t)_n.

Discretizing time as in (8.8) gives the fully discrete iteration

fn(k+1)=fn(k)+τ(pV4(n)fp(k)4fn(k))=(f(k)h)nf^{(k+1)}_n = f^{(k)}_n + \tau \Big( \sum_{p \in V_4(n)} f_p^{(k)} - 4 f_n^{(k)} \Big) = (f^{(k)} \star h)_n

where V4(n)V_4(n) denotes the four neighbors of pixel nn. Each iteration convolves the current image with the same filter:

f(k)=fhh=fkh.f^{(k)} = f \star h \star \ldots \star h = f \star^k h.

The filter has coefficients h0=14τh_0=1-4\tau and h±e1=h±e2=τh_{\pm e_1}=h_{\pm e_2}=\tau; all other entries vanish.

This iteration is stable and converges if 0<τ<1/40<\tau<1/4.

8.2.3 Total Variation Flows

Total variation gradient.

The total variation energy JTVJ_{\text{TV}} is nonsmooth, both in its continuous form (8.2) and in its discrete form (8.6). In the discrete case, JTVJ_{\text{TV}} is nondifferentiable at any image ff with a pixel nn where fn=0\nabla f_n = 0.

If fn0\nabla f_n\neq0 at every pixel, the gradient is

(gradJ(f))n=div(f ⁣f ⁣)n(\mathop{\mathrm{grad}}J(f))_n = -\mathop{\mathrm{div}}\left( \frac{ \nabla f}{ |\!| \nabla f |\!| } \right)_n

The displayed quotient is undefined where the spatial gradient vanishes. Figure 8.4, right, shows the negative TV gradient; normalization by small gradient magnitudes makes it sensitive to perturbations in smooth regions.

Nondifferentiability prevents the use of classical gradient descent at such images. A TV flow can nevertheless be defined through the subgradient inclusion tftJTV(ft)\partial_t f_t\in-\partial J_{\text{TV}}(f_t). Here we first study a smooth approximation.

Regularized total variation.

To obtain a differentiable energy, we smooth the TV prior as follows:

JTVε(f)=nε2+ ⁣fn ⁣2(8.12)J_{\text{TV}}^\varepsilon(f) = \sum_n \sqrt{ \varepsilon^2 + |\!| \nabla f_n |\!|^2 } \tag{8.12}

where ε>0\varepsilon>0 controls the smoothing. Figure 8.5 illustrates the corresponding smoothing of the absolute value function.

Figure 8.5. Regularized absolute value xx2+ε2x \mapsto \sqrt{x^2+\varepsilon^2}.

The smoothed TV energy has gradient

gradJTVε(f)=div(fε2+ ⁣f ⁣2).(8.13)\mathop{\mathrm{grad}}J_{\text{TV}}^\varepsilon(f) = -\mathop{\mathrm{div}}\left( \frac{ \nabla f}{ \sqrt{\varepsilon^2+|\!| \nabla f |\!|^2} } \right). \tag{8.13}

This smoothing interpolates between TV and a rescaled Sobolev energy. For fixed ff,

gradJTVε(f)=Δf/ε+O(ε3)whenε+.\mathop{\mathrm{grad}}J_{\text{TV}}^\varepsilon(f) = -\Delta f/\varepsilon+ O(\varepsilon^{-3}) \quad\text{when}\quad \varepsilon\rightarrow +\infty.

Figure 8.6 displays the regularized spatial-gradient magnitude for several smoothing parameters.

Figure 8.6. Regularized gradient norm  ⁣f(x) ⁣2+ε2\sqrt{ |\!| \nabla f(x) |\!|^2 + \varepsilon^2 }.

Regularized total variation flow.

The smoothed total variation flow is then defined as

ftt=div(ftε2+ ⁣ft ⁣2).(8.14)\frac{ \partial f_t}{\partial t} = \mathop{\mathrm{div}}\left( \frac{ \nabla f_t}{ \sqrt{\varepsilon^2+|\!| \nabla f_t |\!|^2} } \right). \tag{8.14}

Choosing a small ε\varepsilon makes the flow approximate total variation minimization more closely, but requires smaller time steps in explicit discretizations.

In practice, gradient descent (8.8) discretizes this flow in time. For the smoothed total variation flow to converge, a sufficient condition is 0<τ<ε/40<\tau<\varepsilon/4. Thus, a closer approximation to the TV energy requires smaller time steps and more iterations.

Figure 8.3 compares heat flow with smoothed TV flow for a small ε\varepsilon. TV flow preserves edges better than heat diffusion, consistent with the ability of the TV energy to represent sharp transitions.

8.2.4 PDE Flows for Denoising

PDE flows can be used to remove noise from an observation f=f0+wf= f_0 + w. As detailed in Section 7.1.2, a simple noise model assumes that each pixel is corrupted by Gaussian noise wnN(0,σ2)w_n \sim \mathcal{N}(0,\sigma^2), and that these perturbations are independent (white noise).

To denoise, we initialize the PDE flow at the observed image ff at time t=0t=0:

ftt=gradftJandft=0=f.\frac{ \partial f_t}{\partial t} = - \mathop{\mathrm{grad}}_{f_t} J \quad \text{and} \quad f_{t=0} = f.

Stopping the flow defines an estimator f~=ft0\tilde f = f_{t_0}, whose quality depends on the stopping time t0t_0. Figure 8.7 illustrates denoising by Sobolev and TV flows.

Figure 8.7. Denoised images ftf_t at several times tt: Sobolev flow (top) and TV flow (bottom).

On a connected periodic grid, ftf_t converges to a constant image when t+t \rightarrow +\infty, so the choice of t0t_0 balances noise removal against excessive smoothing of image edges. Selecting this stopping time is often difficult. In simulations, if one has access to the clean image f0f_0, one can monitor the denoising error  ⁣f0ft ⁣|\!| f_0-f_t |\!| and choose the t=t0t=t_0 that minimizes this error. Figure 8.8, top row, shows reconstructions obtained with such an oracle choice of stopping time.

8.3 Regularization for Denoising

The flow-based approach in Section 8.2.4 defines the estimator by choosing a stopping time. Alternatively, we can define it as the minimizer of an objective that balances data fidelity and a prior. This formulation also accommodates nonsmooth priors such as total variation JTVJ_{\text{TV}} and sparsity J1J_{1}. Chapter 9 extends it to general inverse problems.

Figure 8.8. Denoising using PDE flows and regularization.

Figure 8.9. SNR as a function of time tt for flows (top) and λ\lambda for regularization (bottom).

8.3.1 Regularization

For a noisy image f=f0+wf= f_0 + w with NN pixels and a prior JJ, consider

fλargmingRN  12 ⁣fg ⁣2+λJ(g),(8.15)f^\star_\lambda\in \underset{ g \in \mathbb{R}^N }{\mathop{\mathrm{argmin}}}\; \frac{1}{2} |\!| f-g |\!|^2 + \lambda J(g), \tag{8.15}

where the regularization parameter λ>0\lambda> 0 balances the data fidelity term  ⁣fg ⁣2|\!| f-g |\!|^2 against the penalty J(g)J(g).

If a clean reference image f0f_0 is available, one can choose the parameter by minimizing the denoising error  ⁣fλf0 ⁣|\!| f^\star_\lambda-f_0 |\!|. Such a reference is rarely available in practice, so parameter selection must account for the noise level and the regularity of the unknown image f0f_0.

For a proper lower semicontinuous convex prior JJ, the quadratic fidelity makes the objective strongly convex, so it has a unique minimizer. For nonconvex priors, minimizers need not be unique; properness, lower semicontinuity, and a lower bound for JJ suffice for existence.

The resulting estimator is

f~=fλ\tilde f = f^\star_\lambda

with λ\lambda chosen according to the noise level and prior.

For a differentiable convex prior JJ, gradient descent for (8.15) takes the form

f(k+1)=f(k)τ(f(k)f+λgradJ(f(k)))(8.16)f^{(k+1)} = f^{(k)} - \tau \left( f^{(k)}-f + \lambda\mathop{\mathrm{grad}}J(f^{(k)}) \right) \tag{8.16}

where τ>0\tau>0 is chosen according to the smoothness of the objective. The iteration adds a data fidelity force to the time-discretized flow (8.8), counteracting the prior’s tendency to smooth the image toward a constant.

Total variation JTVJ_{\text{TV}} and the sparsity prior J1J_{1} are nondifferentiable; the ideal sparsity prior J0J_{0} is also nonconvex. Classical gradient descent therefore cannot be applied directly to (8.15). Computing fλf^\star_\lambda then requires smoothing the prior or using algorithms adapted to nonsmooth objectives, as developed later in the book.

8.3.2 Sobolev Regularization

The discrete Sobolev prior defined in (8.5) is differentiable, and the gradient descent (8.16) reads

f(k+1)=(1τ)f(k)+τf+τλΔf(k).f^{(k+1)} = (1-\tau) f^{(k)} + \tau f + \tau \lambda\Delta f^{(k)}.

Since J(f)=12 ⁣f ⁣2J(f)=\frac12|\!| \nabla f |\!|^2 is quadratic, one can also solve the associated linear system by conjugate gradients.

The solution fλf^\star_\lambda has the explicit linear-system representation

fλ=(IdNλΔ)1f,f^\star_\lambda= ( \mathrm{Id}_{N} - \lambda\Delta )^{-1} f,

Thus, for this prior, the estimator defined by (8.15) depends linearly on the observations ff.

If the differential operators are computed with periodic boundary conditions, this linear system can be solved exactly in the Fourier domain

(f^λ)ω=11+λρω2f^ω(8.17)(\hat f^\star_\lambda)_\omega= \frac{1}{1 + \lambda\rho_\omega^2 } \hat f_\omega \tag{8.17}

where ρω\rho_\omega is determined by the discrete Laplacian; see (8.4).

Equation (8.17) shows that denoising using Sobolev regularization corresponds to low-pass filtering with strength controlled by λ\lambda. Compare this with the solution (8.11) of the heat equation, which uses a Gaussian low-pass kernel with variance 2t2t in each coordinate.

Sobolev denoising belongs to the class of linear estimators studied in Section 7.2. Choosing λ\lambda is therefore a filter-selection problem, as in Section 7.2.2, restricted here to a one-parameter family.

8.3.3 TV Regularization

The total variation prior JTVJ_{\text{TV}} in (8.6) is nondifferentiable. We can either smooth it or use an algorithm designed for nonsmooth optimization.

The approximation JTVε(g)J_{\text{TV}}^\varepsilon(g) defined in (8.12) is differentiable in gg. Substituting its gradient (8.13) into (8.16) gives

f(k+1)=(1τ)f(k)+τf+λτdiv(f(k)ε2+ ⁣f(k) ⁣2).(8.18)f^{(k+1)} = (1-\tau) f^{(k)} + \tau f + \lambda\tau \mathop{\mathrm{div}}\left( \frac{ \nabla f^{(k)}}{ \sqrt{\varepsilon^2+|\!| \nabla f^{(k)} |\!|^2} } \right). \tag{8.18}

For 0<τ<2/(1+8λ/ε)0<\tau<2/(1+8\lambda/\varepsilon), these iterates converge to the unique minimizer of (8.15) with J=JTVεJ=J_{\text{TV}}^\varepsilon.

Section 19.5.1 presents an algorithm for the original nonsmooth TV penalty.