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

Multidimensional Median

The median of n real values x is obtained by taking v(n/2) with v=sort(x) (with a special care for an even number n). It can alternatively obtained by minizing over y the sum of absolute values.

|\sum_i abs(x(i)-y)|

This should be contrasted with the mean that minimizes the sum of squares.

|\sum_i (x(i)-y)^2|

This allows one to define a mutidimensional median for set of points x(i) in dimension d by replacing abs by the d-dimensional norm.

To compute the median in 2D, one needs to minimize the sum of norms. This is not as straightforward as the sum of squares,
since there is no close form solution. One needs to use an iterative algorithm, for instance the re-weighted least squares,
that computes weighted means.

Exercice 1: (check the solution) A first way to denoise the image is to apply the local median filter implemented with the function perform_median_filtering on each channel M(:,:,i) of the image, to get a denoised image Mindep with SNR pindep.

exo1;

Color Image Denoising using 3D Median

Another method computes a multidimensional median for patches located around each pixel of the image.

First we extract the 3D points corresponding to the colors in the patch located around a pixel at a location (x,y).

Exercice 2: (check the solution) Compute the median med of the points in X using the iterative reweighted least squares algorithm. This computed median med should be stored in the result as Mmed(x,y,:) (you need to reshape med so that its size is [1 1 3]).