# Gray Level Image Processing

## Noise Filtering by Averaging

The aim of this treatment is to correct noisy images. We can not apply it if we haven't got multiple images with the same view. Imagine that you laid a camera and you take a burst of photo. In case the images have an additive noise-like white noise, we can denoise to get a sharp image. Noise in an image can come from several reasons, disturbance sensors, transmission of the image, bit errors after digitizing ...

For this study, we add an artificial noise to an image and we will repeat for several noisy images. Since we are dealing with a white noise, it's different for each image. We use the rand function for a uniformly distributed noise. The noise is made as follows:

`bruit=uint8(round((rand(ligne,colonne)*erreur)-erreur/2));`

where error is the maximum error added. We add then noise to the original images to get noisy images. The process is repeated lany times to get more noisy images. We will make 20.

### The Mean

Once the noisy images in our pocession, we make the average of all pixels located at the same coordinates. In other words, the coordinate points (1.1) are summed and divided by the number of image. In Matlab, it is the mean function which performs this computation.

### Program

```clear all; close all; [filename, pathname] = uigetfile({'*.jpg;*.tif;*.PNG;*.gif;*.bmp','All Image Files';...           '*.*','All Files' },'mytitle',...           'C:\Work\myfile.jpg') % récuperation du chemin du fichier x = imread(filename); % récuperation des données if (length(size(x))>2)% si l image en niveau de gris est sur 3 composantes couleurs     x=x(:,:,1);% on prend un seul plan end k=8; [ligne colonne]=size(x);%taille de la matrice %On fait 10 image bruité image_bruit=uint8(zeros(ligne,colonne,10)); erreur=100; nbimage=20; for i = 1 : nbimage     bruit=uint8(round((rand(ligne,colonne)*erreur)-erreur/2));     image_bruit(:,:,i)= x+bruit; end moyenne = uint8(mean(image_bruit,3));  figure(1)  subplot(221)  imshow(x)  subplot(222)  imshow(image_bruit(:,:,1))  subplot(223)  imshow(bruit)  subplot(224)  imshow(moyenne)```