10
Master : EEST Réalisé par: Encadré par: Pr.Youssef EL merabet EL ANZA BOUSSELHA EL BADRI IBRAHIM Année Universitaire : 2015-2016 RAPPORT DU TP DU TRAITEMENT D’IMAGE

devoir traitement d'images

Embed Size (px)

Citation preview

Page 1: devoir traitement d'images

Master : EEST

Réalisé par: Encadré par: Pr.Youssef EL merabet

EL ANZA BOUSSELHA

EL BADRI IBRAHIM

Année Universitaire :

2015-2016

RAPPORT DU TP DU TRAITEMENT

D’IMAGE

Page 2: devoir traitement d'images

Egalisation d’histogramme :

Pour généraliser l’égalisation l’histogramme au cas d’une image couleur il faut

respecter les quatre étapes suivantes :

1. Calcule de l’intensité de l’image couleur I=(R+V+B)/3.

2. Calcule de l’histogramme de I.

3. Calcule de l’histogramme cumulé de I.

4. l’égalisation de l’histogramme dans chaque l’image couleur ?

le programme de l’égalisation une image couleur est :

function C=egalisationcouleur(I);

[w,h,c]=size(I);

if c==3

R=I(:,:,1);

G=I(:,:,2);

B=I(:,:,3);

I=(R+G+B)./3;

end

J=double(I);

H=zeros(256);

HC=zeros(256);

% on peut utilisetr taille=numel(I)

for m=1:w

for n= 1:h

val=J(m,n);

H(val+1)=H(val+1)+1;

end

end

% calcul de l'histogramme cumulé

HC(1)=H(1);

for m= 2:256

HC(m)=(HC(m-1)+H(m));

end

%transformtion de l'image

for m= 1:w

for n= 1:h

val = R(m,n);

C1(m,n)=255*HC(val+1)/(w*h);

end

end

for m= 1:w

for n= 1:h

val = G(m,n);

Page 3: devoir traitement d'images

C2(m,n)=255*HC(val+1)/(w*h);

end

end

for m= 1:w

for n= 1:h

val = B(m,n);

C3(m,n)=255*HC(val+1)/(w*h);

end

end

C=cat(3,C1,C2,C3);

C=uint8(C);

end

Page 4: devoir traitement d'images

3 :: Implémenter la fonction Ngauss qui retourne le noyau gaussian dont la taille et la valeur de sigma sont passées en entrée.

function [J] = Ngauss(I,sigma,taille)

switch taille

case 1

disp('taille 3*3');

[x,y]=meshgrid(-1:1,-1:1);

case 2

disp('taille 5*5');

[x,y]=meshgrid(-2:2,-2:2);

case 3

disp('taille 7*7');

[x,y]=meshgrid(-3:3,-3:3);

end

G=(1/(2*pi*(sigma)^2))*exp(-(x.^2+y.^2)/(2*sigma^2));

J=imfilter(I,G);

J=uint8(J);

imshow(J);

end

I=imread(‘lena.bmp');

J = imnoise(I,'gaussian');

subplot(1,2,1);imshow(I);title('imageoriginal');

subplot(1,2,2);imshow(J);title('imagebruité');

Page 5: devoir traitement d'images

I=imread(‘lena.bmp');

T1S1 = Ngauss(I,0.5,1);

T1S2 = Ngauss(I,1.0,1);

T1S3 = Ngauss(I,1.5,1);

figure ;subplot(1,3,1); imshow(T1S1);title('T 3*3 S 0.5');

subplot(1,3,2); imshow(T1S2);title('T 3*3 S 1.0');

subplot(1,3,3);imshow(T1S3);title('T 3*3 S 1.5');

I=imread('lena.bmp');

T2S1 = Ngauss(I,0.5,2);

T2S2 = Ngauss(I,1.0,2);

T2S3 = Ngauss(I,1.5,2);

figure;subplot(1,3,1); imshow(T2S1);title('T 5*5 S 0.5');

subplot(1,3,2); imshow(T2S2);title('T 5*5 S 1.0');

subplot(1,3,3);imshow(T2S3);title('T 5*5 S 1.5');

Page 6: devoir traitement d'images

I=imread('lena.bmp');

T3S1 = Ngauss(I,0.5,3);

T3S2 = Ngauss(I,1.0,3);

T3S3 = Ngauss(I,1.5,3);

figure;subplot(1,3,1); imshow(T3S1);title('T 7*7 S 0.5');

subplot(1,3,2); imshow(T3S2);title('T 7*7 S 1.0');

subplot(1,3,3); imshow(T3S3);title('T 7*7 S 1.5');

D’après ces image on remarque que plus on augmenté sigma plus l’image

devient flou

Page 7: devoir traitement d'images

La détection de contours avec sobel et prewitt :

function g= contours(I,operateur,direction)

J=double(I);

switch operateur

case 'sobel'

Sx=[-1 -2 -1 ;0 0 0;1 2 1];

Sy=Sx';

case 'prewitt'

Sx=[-1 -1 -1 ;0 0 0;1 1 1];

Sy=Sx';

end

switch direction

case 'horizental'

g=filter(J,Sx);

case 'vertical'

g=filter(J,Sy);

case 'Both'

Gx=filter(J,Sx);

Gy=filter(J,Sy);

g=sqrt(Gx.^2+Gy.^2);

end

g=uint8(g);

imshow(g);

function k=filter(f,o)

[w,h]=size(f);

k=zeros(w,h);

for l=2:w-1

for c=2:h-1

K=o.*f(l-1:l+1,c-1:c+1);

k(l,c)=sum(K(:));

end

end

end

end

Page 8: devoir traitement d'images

l’appelle de fonction :

I=imread(‘carte.bmp’);

sh = contours(I,'sobel','horizental');

sv = contours(I,'sobel','vertical');

sb = contours(I,'sobel','Both');

subplot(1,3,1);imshow(sh);title('sobelhorizental');

subplot(1,3,2);imshow(sv);title('sobelvertical');

subplot(1,3,3);imshow(sb);title('sobel both');

I=imread(‘carte.bmp’);

sh = contours(I,'prewitt','horizental');

sv = contours(I,'prewitt','vertical');

sb = contours(I,'prewitt','Both');

subplot(1,3,1);imshow(sh);title('prewitthorizental');

subplot(1,3,2);imshow(sv);title('prewittvertical');

subplot(1,3,3);imshow(sb);title('prewitt both');

Page 9: devoir traitement d'images

EXERCICE 3 : segmentation par croissance de régions (L P E)

Image I

3 6 5 6 4 6 5 3 4 2 1

6 4 101 100 103 5 3 4 3 2 1

4 3 102 102 102 4 2 3 2 1 3

5 5 99 101 103 4 4 3 4 5 5

4 6 103 104 105 3 4 216 213 210 209

5 3 4 6 5 3 7 214 212 214 100

1 4 2 0 0 5 216 209 211 209 102

0 2 3 2 3 6 212 211 210 213 99

2 4 3 1 3 4 216 206 215 214 99

1 1 2 1 2 6 207 206 213 214 102

1)-segmenter limage I en utilisant G2 et G1 comme image de gradient

Image G2 Image G1

Croissance de régions pour G1 :

1 1 1 1 1 1 1 1 1 1 1

1 1 2 2 2 1 1 1 1 1 1

1 1 2 2 2 1 1 1 1 1 1

1 1 2 2 2 1 1 1 1 1 1

1 1 1 1 1 1 1 3 3 3 3

1 1 1 1 1 1 1 3 3 3 3

1 1 1 1 1 1 3 3 3 3 3

1 1 1 1 1 1 3 3 3 3 3

1 1 1 1 1 1 3 3 3 3 3

1 1 1 1 1 1 3 3 3 3 3

Page 10: devoir traitement d'images

les minima locaux et les germes de l’images G2:

0 0 0 0 0 0 0 0 0 0 0

0 0 0 0 0 0 0 0 1 0 0 0

0 0 0 0 2 0 0 0 0 0 0 0

0 0 0 0 0 0 0 0 0 0 0

0 0 0 0 0 0 0 0 0 0 0

0 0 0 0 0 0 0 0 0 0 0

0 0 0 0 0 0 0 0 0 0 0

0 0 0 0 0 0 0 0 3 0 0 0

0 0 0 0 4 0 0 0 0 0 0 0

0 0 0 0 0 0 0 0 0 0 0

Croissance de régions pour image G2 :

4 4 4 4 4 1 1 1 1 1 1

4 4 2 2 2 1 1 1 1 1 1

4 4 2 2 2 1 1 1 1 1 1

4 4 2 2 2 1 1 1 1 1 1

4 4 2 2 2 4 4 3 1 1 1

4 4 4 4 4 4 4 3 3 1 1

4 4 4 4 4 4 3 3 3 1 1

4 4 4 4 4 4 3 3 3 3 3

4 4 4 4 4 4 3 3 3 3 3

4 4 4 4 4 4 3 3 3 3 3

3) on remarque que dans ce cas on a deux images G1 et G2 on trouver 3 régions pour l’image

G1 et 4 régions pour G2

4)-la méthode de vinet :

D vinet(I,G1)=1-(110-Max(67,0,0)-Max(9,0,0)-Max(34,0,0))/110

D vinet (I,G2)=1-(110-Max(24,0,46,7)-Max(0,12,0,0)-max(0,0,0,21))/110

D vinet =1-(110-46-12-21)/110

Conclusion : d’après l’algorithme de Meyer l’image G1 plus segmenté a l’image G2 (car

Dvinet de G1 =1 mais Dvinet G2= 0,72)

D vinet(I,G1) = 1

D vinet(I ,G2)=1-0.281=0,72