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/');

Velocity Flow Field

A velocity flow is simply a 2-D vector field \(V = (V_i)_{i=1}^N \in \RR^{n \times n \times 2}\) where \(V_i \in \RR^2\) is
one of the \(N=n \times n\) vectors at a position indexed by \(i\).

It can be generated as a realization of Gaussian process. The blurring creates correlations in the flow.

Note that the decomposition \(V=U+W\) is called the Hoge decomposition of the vector field.

Image Advection Along the Flow

A flow defines a warping operator that transport the content of an image along the streaming of the flow.

We load an image \(f\).

name = 'lena';
f = crop( load_image(name, 2*n), n);

Given some vector field \(U\), the warping operator \(f_1 = \Ww_U(f)\) along the flow is define \[ f_1(x) = f(x+U(x)) \] i.e.
it advects the values of \(f\) by the vector field \(U\) to obtain the values of \(f_1\).

In order to visualize the flow, we also advect and diffuse along the flow a density \(g\) of particules, which is a scalar
field. Once \(V\) has been computed, it follows a linear PDE \[ \pd{g}{t} = -(V \cdot \nabla) g + \mu \Delta
g + h \] with some initial condition at time \(t=0\), where \(h\) is a source for the density.

In practice, we solve this PDE in parallel to the PDE for \(V\).

In the following, we use \(W=0\) and \(h=0\) (no sources).

Set the viscosity \(\nu\) for the velocity field.

nu = 1/10;

We use a larger viscosity \(\mu\) for the evolution of the density of particules.

mu = 2*nu;

Extend the warping operator \(\Ww_U\) to work with vector fields as input. This will apply \(\Ww_U\) on each channel of the
vector field (X and Y coordinates).