# What are the use cases of the Dirichlet energy in computer vision?

I am reading a paper, in the context of computer vision, that mentions the "famous" Dirichlet energy. I am not familiar with this Dirichlet energy, but apparently we can minimise it. What are specific use cases of the Dirichlet energy in computer vision and, in particular, calculcus of variations (which I am not familiar with)?

The Dirichlet energy is apparently defined as an integral of the squared norm of the gradient of a function. What's the meaning of this?

The Dirichlet energy is somewhat popular in applications to image processing, computer graphics, geometry processing, and manifold learning, all of which are related to computer vision.

You had two questions, which I'll answer in sort of the opposite order. :)

The Dirichlet energy is apparently defined as an integral of the squared norm of the gradient of a function. What's the meaning of this?

Ultimately, the Dirichlet energy is an operator on functions, which maps them to a scalar number. It also depends on the set $$\Omega$$ over which the function you are interested in is defined. Often in applications this set will be a Riemannian manifold. Let $$u:\Omega\rightarrow\mathbb{R}$$ be a function and define the Dirichlet energy as $$E[u] = \frac{1}{2}\int_\Omega ||\nabla u(x)||^2_2 \,dx$$ Basically, over some region $$\Omega$$, our energy $$E[u]$$ measures how much the function $$u$$ changes over $$\Omega$$. A constant function, for instance, will have zero Dirichlet energy (DE), while a wildly changing function will have high DE. As Wikipedia says, "Dirichlet energy is a measure of how variable a function is".

What is the relation to the calculus of variations?

The variational calculus is something like a "generalization" of the standard calculus approach to finding maxima and minima. For a function $$f$$, we look for extrema by finding points where $$\partial_x f = 0$$. But what if we want the extrema of a functional, i.e., a function of functions? We need to take the derivative of a functional wrt a function (called the "first variation"), and find a function such that we are at a min/max of the functional.

This is often done by considering an energy functional $$J$$ with a Lagrangian $$\mathcal{L}$$ (as you may have seen from optimization theory), for example: $$J[u] = \int_\Omega \mathcal{L}(x,u(x),\nabla u(x)) \,dx,$$ which maps a function (and/or its derivatives) to a scalar energy value, that we want to minimize or maximize. We do this by solving the Euler-Lagrange (EL) equations associated to the energy $$J$$: $$\frac{\delta J}{\delta u} := \frac{\partial\mathcal{L}}{\partial u} - \nabla\cdot\frac{\partial \mathcal{L}}{\partial \nabla u} = 0$$ in the simple case of the energy given as an example above. The term $$\frac{\delta J}{\delta u}$$ is called the functional derivative. This is analogous to solving $$\partial_x f(x) = 0$$ to optimize a function as in 1D calculus (literally, we solve $$\frac{\delta J}{\delta u} = 0$$ instead actually).

What does this have to do with the Dirichlet energy? Well, we can use the calculus of variations to find minimizers of Dirichlet energy by solving the associated EL equations, since the Dirichlet energy is just another energy functional. In this case, the EL equations (assuming boundary conditions with fixed $$u$$) give us Laplace's equation: $$\Delta u = 0$$ In other words, solving Laplace's equation for some $$u$$ is equivalent to minimizing the Dirichlet energy, i.e. solving $$\arg\min_u E[u]$$. The derivations for this are numerous: e.g., [1], [2], [3] [4].

However, an even more general variational connection is given by Dirichlet's Principle (also here): $$\text{If }\; \Delta u + f = 0, \;\text{then }\; u = \arg\min_v \int_\Omega \frac{1}{2}||\nabla v(x)||_2^2 - v(x) f(x) \, dx$$ where $$v=g$$ on $$\partial\Omega$$. Note that $$\Delta u + f = 0$$ is a Poisson equation, which we see pop up in some interesting applications.

This variational connection to the Laplacian is extremely significant, as it for example brings connections to harmonic functions, fundamental PDEs like the heat equation (e.g., [1], [2]), and stochastic processes. The Laplacian itself is enormously important (e.g., [1], [2], [3]), and it is often through the Laplacian and its associated PDEs that the Dirichlet energy is related to applied problems. For instance, an application might only discuss Poisson PDEs, but in fact this is implicitly solving an optimization problem involving the Dirichlet energy.

What are specific use cases of the Dirichlet energy?

Beyond 2D computer vision, there are applications to geometry processing and computer graphics, which are both deeply tied to 3D computer vision.

Image Processing

One simple application is to image segmentation. Intuitively, a single region segment should have very low gradient (i.e., the DE on a single segment should be low). This is part of the basis of the famous Mumford-Shah functional, written $$E_\text{MS}[J,b] = \gamma\int_D |I(p) - J(p)|^2 \,dp + \alpha \int_{D\setminus b} ||\nabla J(p)||_2^2\, dp + \beta\int_b ds$$ for an image $$I$$ over domain $$D$$, and model $$J$$ with boundary $$b$$. where you can see the DE appear as one term.

Since minimizing the DE can be used to penalize noisy (indeed, high frequency in a literal sense) image regions, it can be used for image smoothing and denoising as well. Often, especially in computer vision, the DE is used in deep learning loss functions without even being named (e.g., here), probably since the basic idea to enforce smoothness this way is so trivial.

Surface Parametrization

An interesting application appears in the computation of (discrete) conformal maps. See e.g. Floater and Hormann, Surface Parameterization: a Tutorial and Survey. The idea is to parametrize a discrete surface (e.g., a 3D mesh), in an angle-preserving way. Think of unfolding a globe into a flat map, but distorting it as little as possible. This allows texture mapping and other kinds of surface manipulations in graphics and vision.

Mathematically, it uses the conformal energy $$E_C$$, which measures how closely the mapping satisfies the Cauchy-Riemann equations, to enforce conformality. It turns out this is equivalent to minimizing the Dirichlet energy minus the mapping area.

Correspondence and Feature Extraction

Computer vision, particular 3D shape correspondence, alignment, and tracking, often requires maps between two discretized surfaces $$A$$ and $$B$$. The DE again shows up in a optimization problem to compute the Laplacian eigenbases, which can be manipulated for computing correspondences between shapes and/or descriptive features for tasks like retrieval or learning. See e.g. here or here. Another idea is to use a soft map, which computes a probability distribution over $$B$$ for each point on $$A$$. One way to help enforce continuity of such maps is to use a form of Dirichlet energy. See Soloman et al, Dirichlet Energy for Analysis and Synthesis of Soft Maps for details.

Geometric Deep Learning

Recent work in machine learning seeks to generalize network architecture to handle manifold-valued data and signals defined on manifolds. In the former case, the DE's connection to the Laplacian (and its associated PDEs and eigenbasis) links it to the differential geometry of each datum; in the latter case, signals on manifolds (or graph-based analogues thereof) can be e.g. smoothed by minimizing the Dirichlet energy. Non-Euclidean data (e.g., 3D shapes) are prevalent in computer vision, and starting to be handled via learning methods now. A good intro to this topic is this survey paper. This view of the DE requires some functional analysis and Riemannian geometry (considering the Hilbert space of fields on these manifolds, with inner product given by integrating over it, requiring one to use the metric tensor of the space to account for the local geometry).