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

RGB Color Space

A color image \(f \in \RR^{N \times 3}\) is made of three independent images, one for each channel red, green and blue (RGB
color space).

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

n = 256;
N = n*n;

Loading an image \(f \in \RR^{N \times 3}\).

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

One can display on screen a color image in RGB space using the rule of additive color mixing.

Display the image \(f\) and the three channels that compose the colors.

HSV Color Space

A non-linear color space is obtained by a polar or conical parameterization of a linear color space. The angular coordinate
in the plane orthogonal to the first linear axis (which is usually the luminance) is called the Hue, and the radial coordinates
is called the saturation.

Using a luminance which is the sum of the 3 coordinates, one obtain a color system that is quite close to the HSV color system
(which has a more complicated definition, but leads to similar results).

First we compute the value (luminance) coordinate, which is the orthogonal projection on \([1, 1, 1]\).

Value = @(f)sum(f, 3) / sqrt(3);

The we compute the projection on the plane orthogonal to \([1, 1, 1]\), for instance using the projections \(A\) and \(B\)
on the two orthognoal unit vectors \[ [0, 1, -1]/\sqrt{2} \qandq [2, -1, -1]/\sqrt{6}. \]

The image, withing this new color space, can be manipulated. Here we lower the chrominance of the image. The result is slighly
less visible than with YUV modification because the color space is more adapted to the image.

g1 = g;
g1(:,:,2:3) = g1(:,:,2:3)/2;

Exercice 3: (check the solution) Inverse the PCA transformation in order to retrive an image the modified PCA representation U1.

exo3;

Color Histograms

To better understand the colors structure of an image, it is useful to visualize histogram of the color repartition.

Color Image Denoising and Compression

Color image denoising is more difficult than grayscale denoising because independant denoising of RGB channels introduces
color artifact. For image with homogenous colors, it can be avoided by using an appropriate color space.

Noise level.

sigma = .13;

A noisy image color image \(f_1\) is corrupted by a color Gaussian noise.

f1 = f + randn(n,n,3)*sigma;

Display.

clf;
imageplot(f, 'f', 1,2,1);
imageplot(clamp(f1), 'f_1', 1,2,2);

Exercice 4: (check the solution) Compare (translation invariant) wavelet denoising of color image in the RGB and PCA color space (the PCA space should be
estimated from the noisy image).

exo4;

Exercice 5: (check the solution) For a complicated, non-homogenous color image, compute a local color space for each pixel, by performing a PCA over group
of pixels. Use this adaptive color model to perform wavelet denoising.