CS 7960 - Project 2

Anisotropic Diffusion

Name: Jonathan Bronson
Date: Feb 24, 2010

Table of Contents

  1. Introduction
  2. Isotropic Diffusion
  3. Anistropic Diffusion
  4. Nonlinear Scale-Space
  5. Results
  6. Conclusion
anisotropic diffusion anisotropic diffusion

1. Introduction

Overview
The goal of this project is to implement and better understand the work by Perona & Malik on Anistropic Diffusion. Their framework shows that a small change to the heat equation or diffusion equation can not only preserve edges in images, but often enhance them as well. Further, we will see how a Nonlinear Scale-Space can be created to better capture the structure of the image for segmentation.

Design Choices

For this project and future projects for this course, I will continue to build a comprehensive framework application. This application allows me to easily open and save images using a GUI, and quickly access all previous projects through their respective toolbox's. Using an MDI display model allows myself or another user to have any number of images open at one time, and compare results of methods more easily.

My implementation is coded in C++, using Qt for the GUI, and VISPack for image handling. I use CMake to automate the build process and except for some limitations of VISPack, the application is completely cross-platform. The software has been successfully built on OpenSUSE, Ubuntu, and Windows 7.

Back


2. Isotropic Diffusion

The diffusion equation, or Heat Equation, is a partial differential equation which describes the cooling (heat diffusion) of some continuous material. It can actually be shown that for an isotropic material, the diffusion equation results as if the field were convolved with a Gaussian kernel. It is this equivalence that makes diffusion a viable implementation method for generating Gaussian Scale-Space images. For an image I the diffusion equation can be written as:

One way to implement this is to convolve the image with a discrete laplacian kernel, and add the result back to the original image. This formulation can be solved directly at once, written out as:

This is known as the Forward Time Central Space (FTCS) method. Care must be taken to scale lambda such that the method remains numerically stable. Perona and Malik suggest stable values fall in the range . A more stable method would be to solve the system implicitly, using the Backward Time Central Space (BTCS) method. However, while more stable, it will ultimatley be slower to compute.

Back


3. Anisotropic Diffusion

In a landmark paper, Perona and Malik showed that a simple change to the heat equation could produce a tremendously valuable tool in image processing. Rather than assuming a constant conductivity value for the material (image), they propose the use a flux function c. This newly formulated anistropic diffusion equation is written as:

Further expanding the terms yields:

What makes this formulation so powerful is the flux function dictates at what rate diffusion takes place at any given point in the field. For instance, using a flux function dependent on gradient magnitude allows us slow, or even halt diffusion along image edges. This creates a very robust image smoothing algorithm. Further, the flux function allows for what is physically impossible, inverse diffusion. The effect of such inverse diffusion is the enhancement or strengthening of edges. Perona and Malk suggested two possible flux functions:

and

The first flux function (left) favors preserving edges, while the second function (right) favors smooth large regions. I've implemented both for this project, and it is clear which function to use is dependent on both the properties of the input image, as well as the desired output.

Implementing Anisotropic Diffusion can be done in a fashion similar to that of the isotropic case. It is slightly more complicated only because we cannot use the image laplacian directly, since each partial derivative is scaled by a different flux value. We can thus implement it as:

In this notation, the alphanumeric subscripts correspond to North, South, East and West pixels of the current location (i,j). This is convenient since the flux values are actually stored on edges, index notation would force us to denote them with half indices. Further, since we ultimately only care about the gradient magnitude, it makes no difference if we take the forward gradient or the backward gradient, as long as we are consistent.

Back


4. Non-Linear Scale-Space

Utilizing the anistropic diffusion equation, we can now create a non-linear scale-space in the same manner we created a Gaussian scale-space. However, the additional free parameter of K, as well as the choice for the flux function, leaves some ambiguity as to what the ideal non-linear scale-space will be. More than likely, the choices will be image dependent, and at best we can use some heuristics to obtain good choices. For the images in this paper, values of K were chosen by user selection.

Below is a comparison of three scale-spaces generated from an input image. The first is standard Gaussian scale-space, created using isotropic diffusion. The other two are created using anistropic diffusion with the two different flux functions mentioned in the earlier sections. In addition, the gradient maps of the varying image levels are shown for comparison.
For the two anisotropic scale-spaces, the flux functions took K = 0.4

ScaleLinearQuadraticExponential
t = 0
t = 1
t = 4
t = 16
t = 64
t = 256

From the images alone, it is clear something very different is going on in the non-linear scale-space. First, the isotropic or Gaussian scale-space has no regards for boundaries within the image. This makes sense, as it assumes the least about the underlying image. The quadratic flux function takes into account gradient, but as Perona & Malik say, favors broad areas. This leads to a mild bleeding effect, not unlike water color paintings. Last, the the exponential flux function, which favors strong edges, blurs the least, while smoothing out regions of continuous texture. Looking at the gradient maps reveals more information.

ScaleLinearQuadraticExponential
t = 0
t = 1
t = 4
t = 16
t = 64
t = 256

We can see from the gradient maps of each image how the different flux functions transform the input image through scale-space. Recall, the isotropic diffusion can be considered a constant flux function. With no regard for edge information, we see they disappear rapidly upward in scale-space. Not only does their magnitude fade, but they expand in width as well. Conversely, the quadratic and exponential flux functions have a different affect on edges.

First, edges of all types are preserved longer than in the isotropic case. Additionally, the stronger edges last longer, such that high level images retain only the most dominant edges. The effect appears more pronounced in the quadratic case simply because the flux function is more willing to smooth them out. For instance, in the top scale the quadratic function captures only the outline of the American flag, while the exponential function captures the inner lines as well.

The exponential flux function also has an additional side effect. Edges which were not strong in the input image, become more and more pronounced in the higher scales. In the images above, the most evident case of this is the edge between the clouds and sky.

Back

5. Results

To better illustrate the difference values of K can make, between the flux functions, additional examples are shown below.
Input ImageQuadratic
K=0.08
t=64
Exponential
K=0.08
t=64


Input ImageQuadratic
K=0.12
t=20
Exponential
K=0.15
t=20

From the images above, it should be clear that the quadratic flux function and the exponential flux function suffer from opposite problems. The quadratic function nicely smooths out all shot noise, but blurs away all detail very quickly. The exponential function preserves better edge detail, but lacks the ability to remove the shot noise. In fact, some locations of noise get amplified as they are mistaken for strong edges. This fact is the motivation for the follow-up paper by Yu and Acten on Speckle Reducing Anisotropic Diffusion.

Input Image Quadratic
K=0.035
t=64
Exponential
K=0.035
t=64
Exponential
K=0.15
t=64

The figures of the spine above show that for some images, the choice of flux function and K value are tightly related. The same K value will produce very different results between the Quadratic and Exponential functions. However, one can see that when we increase K substantially for the exponential function, the resulting image looks more like the result from the lower K-valued Quadratic function.

Back


6. Conclusion

As James Fishbaugh discussed in lecture, Non-Linear Scale-Space is not hands down better than Gaussian Scale-Space. For instance, Gaussians have nice properties, such as being linearly separable as well as the property that the convolution of two Gaussians is a third Gaussian, equal to the sum of their variances. This makes the Linear Gaussian Scale-space easy to compute, while still respecting the causality criteria. The reasons we would favor this new Non-Linear Scale-Space include better localization of coarse scales, and the retainment of edge features. This can be seen as a piece-wise smoothing.

One way to improve the effectiveness of Anisotropic Diffusion would be to automatically obtain the ideal K values for the image. We could obtain such an ideal value by examining a histogram, or PDF of the image gradient. Then, we could choose a value corresponding to the perceived noise-edge ratio. A more advanced approach would be to identify various peaks in the PDF and choose multiple K values to segment varying levels of details in the image. It's clear from these results that even without such improvements, anisotropic diffusion is a powerful tool for image processing.

Back