0% found this document useful (0 votes)
0 views7 pages

Compte Rendu TP2: Exercice 01

Tp2

Uploaded by

khaled.elahmar
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
0 views7 pages

Compte Rendu TP2: Exercice 01

Tp2

Uploaded by

khaled.elahmar
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 7

Compte rendu TP2

Exercice 01 :
% Lire l'image "photo00.bmp" et l'affecter à la variable Im
im = imread('photo00.bmp');
% Afficher l'image (figure 1)
figure(1);
imshow(im);

% Donner l'histogramme de Im
h = imhist(im);
stem(0:255, h);
title('Histogramme de l''image');
% Donner l'histogramme normalisé de Im
% Donner l'histogramme cumulé de Im
% Donner l'histogramme cumulé normalisé de Im
[nL, nC, m]=size(im);
hn=h/(nL*nC);
hc=cumsum(h);
hcn=cumsum(h/(nL*nC));
subplot(3,2,1:2) ,imshow(im) ,title('image'),
subplot(3,2,3) ,stem(0:255,h) ,title('histogramme'),
subplot(3,2,4) ,stem(0:255,hc),title('histogramme cumulé'),
subplot(3,2,5) ,stem(0:255,hn) ,title('histogramme normalisé'),
subplot(3,2,6) ,stem(0:255,hcn) ,title('histogramme cumulé normalisé')
im=imread('col01.jpg');
R=im(:,:,1);
Hr=imhist(R);
V=im(:,:,2);
Hv=imhist(V);
B=im(:,:,3);
Hb=imhist(B);
subplot(3,3,2) ,imshow(im) ,title('col'),
subplot(3,3,4) ,stem(0:255,Hr,'r'),title('Hr'),
subplot(3,3,5) ,stem(0:255,Hv,'g'),title('Hv'),
subplot(3,3,6) , stem(0:255,Hb,'b') ,title('Hb'),
subplot(3,3,8) ,stem(0:255,Hr,'r'),hold on ,stem(0:255,Hv,'g'),
stem(0:255,Hb,'b'),title('Hcol')
P1=imread('photo01.bmp');
[nl1, nc1]=size(P1);
P2=imread('photo02.bmp');
[nl2, nc2]=size(P2);
P3=imread('photo00.bmp');
[nl3, nc3]=size(P3);
L1 = mean2(double(P1));
C1 = sqrt(sum(sum((double(P1)-L1).^2))/(nl1*nc1));
L2 = mean2(double(P2));
C2 = sqrt(sum(sum((double(P2)-L2).^2))/(nl2*nc2));
L3 = mean2(double(P3));
C3 = sqrt(sum(sum((double(P3)-L3).^2))/(nl3*nc3));
subplot(3,2,1) ,imshow(P1) ,title(['L=' , num2str(L1),'C= ' , num2str(C1) ]),
subplot(3,2,2) ,stem(0:255,imhist(P1)),
subplot(3,2,3) ,imshow(P2) ,title(['L=' , num2str(L2),'C= ' , num2str(C2) ]),
subplot(3,2,4) ,stem(0:255,imhist(P2)),
subplot(3,2,5) ,imshow(P3) ,title(['L=' , num2str(L3),'C= ' , num2str(C3) ]),
subplot(3,2,6) ,stem(0:255,imhist(P3))
Exercice 2 :
%% Inversion Dynamique :

ng = 0:255;
LUT1 = 255-ng;
plot(ng,LUT1)
title(' Inversion Dynamique :')

%% Transformation logarithmique:

LUT2 = 255*log(1+ng)/log(1+255);
plot(ng,LUT2)
title(' Transformation logarithmique:')
% Dilatations linéaires :

subplot(1,2,1)
a=20; b=100;
for i=1:256
if ng(i)>=0 && ng(i)<=a
alpha=b/a;
beta=0;
LUT3(i)=alpha*ng(i)+beta;
else
alpha=(255-b)/(255-a);
beta=255*(b-a)/(255-a);
LUT3(i)=alpha*ng(i)+beta;
end
end
plot(ng,LUT3)
title('Dilatations linéaires (20/100)')

subplot(1,2,2)
a=60; b=20;
for i=1:256
if ng(i)>=0 && ng(i)<=a
alpha=b/a;
beta=0;
LUT3(i)=alpha*ng(i)+beta;
else
alpha=(255-b)/(255-a);
beta=255*(b-a)/(255-a);
LUT3(i)=alpha*ng(i)+beta;
end
end
plot(ng,LUT3)
title('Dilatations linéaires (60/20)')
%% Correction gamma:
Y = [0.2,0.5,0.7,0,1,0,1.2,1.5,1.7];
for i=1:9
if i==4||i==6
continue
else
subplot(3,3,i)
LUT4 = 255*ng.^Y(i)/255^Y(i);
plot(ng,LUT4)
title('Correction gamma: ',Y(i))
end
end

You might also like