Annie Ernaux Extérieurs. pptx. Exposition basée sur un livre .
devoir traitement d'images
1. 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
2. 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);
4. 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é');
5. 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');
6. 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
7. 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
8. 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');