Warning: jsMath
requires JavaScript to process the mathematics on this page.
If your browser supports JavaScript, be sure it is enabled.

Tensor-driven Diffusion Flows

This numerical tour explores the structure tensor to represent the geometry of images and textures. It applies it to perform
anisotropic image diffusion. A good reference for diffusion flows in image processing is [Weickert98].

Installing toolboxes and setting up the path.

You need to unzip these toolboxes in your working directory, so that you have toolbox_signal and toolbox_general in your directory.

For Scilab user: you must replace the Matlab comment '%' by its Scilab counterpart '//'.

Recommandation: You should create a text file named for instance numericaltour.sce (in Scilab) or numericaltour.m (in Matlab) to write all the Scilab/Matlab command you want to execute. Then, simply run exec('numericaltour.sce'); (in Scilab) or numericaltour; (in Matlab) to run the commands.

Execute this line only if you are using Matlab.

getd = @(p)path(p,path); % scilab users must *not* execute this

Then you can add the toolboxes to the path.

getd('toolbox_signal/');
getd('toolbox_general/');

Helpers Functions

We define here a few features (convolution, gradient, etc.) that will be used in the sequel.

Size of the image of \(N=n \times n\) pixels.

n = 256;

Load an image \(f\).

name = 'hibiscus';
f = load_image(name,n);
f = rescale( sum(f,3) );

Display it.

clf;
imageplot(f);

We define circular convolution \[ (f \star h)_i = \sum_j f_j h_{i-j}. \] Note that here, \(f\) can be multi-channel, in which
case each channel is convolved with \(h\). This will be useful to blur tensor fields.

The matrix \(T_\si(x)\) can be understood as the local covariance matrix of the set of gradient vector around \(x\).

Another way to get some insight about this tensor field is to consider a localized version \(f_x\) of the image around point
\(x\), defined by \(f_x(y) = h_\si(x-y)^{1/2} f(y)\), which is close to zero when \(y\) is far away from \(x\). One has the
following Taylor expansion of the \(L^2\) norm between two close enough localizations: \[ \norm{f_x - f_{x+\de}}^2 = \de^*
T_\si(x) \de + O(\norm{\de}^3). \]

To better understand the behavior of \(T_\si\) as a function of \(\si\), one can computes its Taylor expansion for small \(\si\)
\[ T_\si(x) = T_0(x) + \si^2 Hf(x)^2 + O(\si^3), \] where \(Hf(x) \in \RR^{2 \times 2}\) is the Hessian matrix of \(f\) at
point \(x\). This shows that when \(\si\) increases, the intial rank-1 tensor \(T_0(x)\) becomes full rank because it integrates
energy from \(Hf(x)^2\).

A convenient way to display a tensor field such as \(T_\si\) is to draw an ellispe \(\Ee_x\) at each pixel \(x\) as the (scaled
and translated) unit ball of the tensor \[ \Ee_x = \enscond{\de \in \RR^2}{ \de^* T_\si(x) \de \leq 1 }. \] This allows one
to visualize the anisotropy and orientation encoded in the tensor field.

Note that this remapping of the eigenvalues of \(T\) to the eigenvalues of \(S\) exchanges the roles of the eigenaxes. This
causes the diffusion to be stronger along the edges, and to be small perpenticular to it.

This flow can thus be seen as an anisotropic version of the famous Perona-Malick flow [PerMal90]. Note that the Perona-Malick flow is often refered to as an anisotropic diffusion, but it is actually incorrect, because the diffusion tensor associated to is is actually isotropic, since it corresponds
to using a time-dependent tensor field \[ S(x) = \phi(\norm{\nabla f_t(x)}) \text{Id}_2 . \]

Shortcut for the multiplication \(S u\) of tensor \(S\) by vector field \(u\).