Geodesic Segmentation

This tour explores the use of Fast Marching methods for image segmentation.

Contents

Installing toolboxes and setting up the path.

You need to download the following files: signal toolbox, general toolbox and graph toolbox.

You need to unzip these toolboxes in your working directory, so that you have toolbox_signal, toolbox_general and toolbox_graph 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/');
getd('toolbox_graph/');

Segmentation Using Geodesic Ball

It is possible to extract an object by growing a geodesic ball.

First we load an image.

n = 256;
name = 'cortex';
M = rescale( sum(load_image(name,n),3) );

Display.

clf;
imageplot(M);

Starting point of the grodesic ball.

pstart = [154;175];

Choose a metric that is minimal for value of the image close to pstart.

W = abs(M-M(pstart(1),pstart(2)));
W = rescale( max(W,0.03), 0.01,1).^2;

Compute the Fast Marching from the center.

clear options;
options.nb_iter_max = Inf;
options.end_points = [];
[D,S,Q] = perform_fast_marching(1./W, pstart, options);

Exercice 1: (the solution is exo1.m) Display geodesic balls {x \ M(x)<T} for various T.

exo1;

Segmentation Using Voronoi Diagrams

It is possible to perform the segmentation by using an edge stopping metric, and Vornoi diagram for several seeds.

Magnitude of the gradient.

mu = 2;
d = sqrt( sum( grad(perform_blurring(M,mu)).^2, 3) );
d = perform_blurring(d,mu);

Edge stopping metric.

W = rescale( min(d,0.15), 0.01,1).^2;

Display the metric.

clf;
imageplot(W);

Starting points.

pstart = [[30;30] [139;86] [158;170] [128;134] [124;122]];

Perform propagation.

options.nb_iter_max = Inf;
options.end_points = [];
[D,S,Q] = perform_fast_marching(1./W, pstart, options);

Display Voronoi diagrams.

clf;
imageplot(Q);
colormap(jet(256));

Exercice 2: (the solution is exo2.m) Display the level sets.

exo2;