A model that works perfectly fine in every single case. Unfortunately, models that get closer to this tend to be very complex and, as a consequence, unpractical. Sometimes the best thing is to focus on a particular case and use all the assumptions that come with it in your favor and then devise a model to solve this particular class. In the following, we are going to work through image restoration models. The concepts introduced here will be motivated using the problem of *Image Denoising*.

## An example from politics

Try to answer the question: Who is going to be the next president of Brazil?

It could be very hard to answer, even if you are a Brazilian. Nonetheless, you can be more confident on your answer if additional pieces of information are given. For example, your guess will be different in each of the scenarios below.

- Candidate Beto is involved in a corruption scheme.
- Candidate Amanda has 70% of votes one week before elections.
- The current government passes through a serious economic and political crisis and the current vice-president is an unscrupulous person.

The key idea here is to use available information or to *assume reasonable hypotheses* for your problem that helps you to solve it.

## Image denoising problem

You are given an image in which some of its pixels are corrupted by *noise*. By noise, I mean any set of unexpected pixels that together do not add any information to the description of the image. Those noise pixels can occur, for example, as a consequence of an interference in the data transmission or due to the quality of the equipment used.

In the denoising problem, one has as input a noisy image and wants to recover the image without noise (the perfect image) . By denoting the noise component as , the problem can be written mathematically as:

The noise component is well modeled by a Gaussian with zero mean and unit variance (the Central Limit Theorem offers one reason why).

The denoising problem is an example of an *inverse problem*. It is straightforward to corrupt an image. You just need to add a noise component. One can generate countless corrupted images by this process, and that’s one of the reasons why it is so difficult to recover the original perfect image. In general, inverse problems are difficult to solve.

## A bayesian model for image denoising

Let and to be two events in some sample set . Recall that:

Then, Baye’s theorem says:

We can use Baye’s theorem to devise a way to work out the denoising problem. The strategy will be to find the value that maximizes the probability of conditioned to the noisy image . In mathematical notation:

This technique is also known as *Maximum a Posteriori (MAP)*.

At a first glance, this approach seems useless, as we don’t have a direct expression for . However, by using Baye’s theorem, we can derive one. Firstly, note that we can write, indeed, the conditioned probability in the other direction:

Applying Baye’s theorem:

The value of plays no role in the maximization of , so we can just ignore it. The probability , on the other hand, must be supplied. Here takes place our prior assumption.

I claim that the perfect image has small *total variation *. The formal definition of the total variation of a function is not so straightforward (read more here), but it is enough for us to say that:

The total variation assumption is reasonable because it is natural to imagine that an image is a set of regions (objects) in which its intensity level (or color) variation is zero or close to zero in its interior (see Mumford-Shah functional).

In order to use MAP, we need to attach a probability distribution to the total variation energy . There are reasons that lead us to use the *Gibbs Distribution* (more about those reasons later):

By replacing it in our maximization problem:

Now we apply a series of tricks to make our life easier. First, as is monotonically increasing we can rewrite the expression above as:

The term inside the is a constant, and can be eliminated. Further, we can remove the minus signs by computing the equivalent argmin problem:

## Other Priors

A prior is a special information available to the problem you want to solve. Different priors will work better for different problems. For example, if one wants to segment an image in which one priorly knows that the image contains straigth-line contours, maybe it is a good idea to use a curvature prior. The exploited property here is that straight lines have zero curvature.

## On the Gibbs distribution

In order to use the MAP (maximum a posteriori) framework, one first defines an energy function (the prior energy, for example, total variation), and then uses the Gibbs distribution to have an expression for . The question that now arises is: What is the motivation to use the Gibbs Distribution? The answer is not clear to me at the moment, but I have some clues that I am going to investigate further.

The origins of Gibbs distribution in image models dates back to a paper from Hassner and Sklansky (The Use of Markov Random Fields as Models of Texture). To make the connection with Gibbs distribution, there exists a result that states the equivalence between Markov Random Fields (MRF) and Gibbs Distribution (link).

## Further reading

**[1]** – Martin **Burger** and Stanley **Osher**: A guide to the TV Zoo.

**[2]** – Antonin **Chambolle**, Vicent **Casseles**, Matteo **Novaga**, Daniel **Cremers**, Thomas **Pock**: An introduction to total variation for image analysis.

**[3]** – Martin **Hassner** and Jack **Sklansky**: The Use of Markov Random Fields as Models of Texture.

**[4]** – Emanuel **Levitan**, Michael **Chan** and Gabor T. **Herman**: Image-Modeling Gibbs Priors.

**[5]** – Giovanni **Sebastiani** and Fred **Godtliebsen** : On the use of Gibbs priors for Bayesian image restoration.