# Comparison of Bilateral Filter and Anisotropic Diffusion

What are the advantages / disadvantages of bilateral filter and anisotropic diffusion for noise reduction?

EDIT: To be more specific - what are the practical differences in terms of quality, speed or flexibility? How should I choose whether to use AD or BF for noise reduction?

• Can you give some more specifics? Are you looking to apply those methods to some domain? Are you interested from a theoretical point of view? (i.e. want to pursue a certain research direction) – visoft Oct 25 '13 at 9:36
• @visoft I'm implementing a segmentation algorithm (doras.dcu.ie/4677/1/DG_Ctex_oct_2008.pdf) that uses AD for noise reduction. I'm curious why not BF. What are their practical differences of AD and BF in terms of quality, speed or flexibility? – fhucho Oct 25 '13 at 9:46
• @visoft edited the question. – fhucho Oct 25 '13 at 9:51

Your question is a bit harsh, because it's kind of vague. I will give you a few points, maybe it will help.

What's the same?

The intuitions behind both bilateral filtering and anisotropic diffusion are the same:

• averaging is good to remove random noise;
• averaging should only concern pixels that belong to the same region (in the sense that they are pixels of a given color of a given object):
1. to avoid artifacts at the borders between regions (most notably, blur)
2. to improve the denoising efficiency (without outliers inside, averaging is more efficient).

What's different?

Bilateral filtering and anisotropic diffusion will differ by how they achieve these two goals (under the constraint that an image segmentation is not available).

Usually, anisotropic diffusion is expressed in a variational framework, where some image functional is minimized. These functionals usually include a term that depends on the gradient of the image to be denoised, because this term allows to trigger the anisotropy property. The solutions to these problems are usually obtained iteratively via some gradient descent, but not always (in image morphology inspired frameworks such as mean curvature motion for example, image level lines are moved according to their curvature).
Basically, the solutions to these functionals correspond with isotropic diffusion inside homogeneous areas, and diffusion across image edges is stopped by a weight depending on the image gradient.

Bilateral filtering is a pixel-based approach. For a given pixel, its denoised counterpart is obtained by the weighted average of its neighbours, where the weights are given by some function that depends on their color similarity and image distance. Unlike anisotropic diffusion then, the problem is not solved globally over the image but over each a neighbourhood surrounding each pixel. Furthermore, there is no explicit gradient-based barrier at a given pixel: this effect will be more or less pronounced by the value of the decay put in the visual distance function.

Note that when the bilateral neighborhood of a pixel goes infinite, you have a new algorithm called nonlocal means.

And now.. the speed

In terms of quality, I would consider that either approach is good. Anisotropic diffusion has some caveat though:

• since it's usually implemented as some gradient descent or PDE solver, a quick-and-dirty implementation can run into numerical issues;
• in my opinion, it's easier to tune the decay of the distance function in bilateral filtering than the data term in anisotropic diffusion functionals.

Remains the speed... This part depends a lot on the practical implementation.

When bilateral neighborhood size gets large (OpenCV claims large is above 5 pixels) then bilateral filtering is slow. You can use some tricks (Gaussian approximated by boxes, pre-selection criterion...) to accelerate the code. In fact, there's even a significant part of the literature on bilateral filtering that is dedicated to speeding it up.

For anisotropic diffusion, it depends in the numerical scheme implemented to solve the problem. Some are better (faster and more stable) than others: typically, TV regularized constraint is nowadays implemented with Chambolle's projectors (fast) or with Nesterov's acceleration (see FISTA -- faster). Furthermore, these schemes are well suited to massively parallel implementations (GPGPU, data parallel multithreading) that reduce greatly the computation time.

• Thanks, marking as accepted for now. Sorry for the vagueness, I added more details. – fhucho Oct 25 '13 at 11:08
• I've updated the answer with a speed section. However, imo, speed should not be a criterion of choice. Use the approach that you are the most comfortable with in order to easily and quickly tune the parameters. – sansuiso Oct 25 '13 at 11:19
• @sansuiso: +1; nice answer. – Jason R Oct 25 '13 at 14:48
• @sansuiso, Great answer. some PDE's are quite fast with no "Solver". Have you seen David Tschumperlé's Fast Anisotropic Smoothing of Multi-Valued Images using Curvature-Preserving PDE's? What do you think about it? – Royi Jun 8 '14 at 13:11
• Tschumperlé's work is actually one form of anisotropic diffusion. You can choose the mathematical where you are the most comfortable. – sansuiso Jun 10 '14 at 10:51

Following the intuitive answer from @sansuiso, it's important to remember the parameters for the two methods and what kind of filtering they produce:

BF: $\sigma_s$ (space), $\sigma_r$ (intensity range) (geometrical interpretation the geodesic distance, to be set) usually $\sigma_s$ is fixed and $\sigma_r$ is chosen to be the gradient function.

NLmeans: The NL-means algorithm estimates the value of pixel $x$ as an average of the values of all the pixels whose Gaussian neighborhood looks like the neighborhood of $x$, thus resolving the problem of find a good kernel size.

AD: The non local diffusivity constant $c$ and the time constant/stopping criterion for the diffusion.

For certain conditions a single iteration of the BF produces multiple iterations of various weighted filters and variational schemes given a good choice of the penalty function.

This report contains a good overview of the different variational filters, penalty functions, iterative thresholding methods (like FISTA)