Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 8

Compte rendu TP 1: Manipulation et transformation des

images numériques

I. Lecture, visualisation et sauvegarde d’images


Code Matlab:
clc; clear all ; close all

aa= addpath(' C:\images');


Im1=imread (' lena.bmp')
figure(1),imshow(Im1)

figure(2), subplot (1,2,1),images (Im1)


subplot (1,2,2),imshow(Im1),
[m n]=size(Im1);
Im1a=im2double(Im1);
Im1b=double(Im1);

a=Im1(120,200)
Im2=Im1(79:178,79:178);
[m n]=size(Im2);
figure (4),imshow(Im2)

imwrite(Im2,'lenapart1.jpg');
imwrite(Im2,'lenapart2.bmp');

Im2a=imred('lenapart1.jpg');
Im2a=imred('lenapart1.jpg');
figure(5),subplot(1,2,1),imshow(Im2a)
Résultats:

II. Systèmes de représentation de couleurs et de types d’images


Clown
1)Code:
Clc ; clear all; close all;
Im1=imread(‘D:\images2020\clown.bmp’)
Figure, imshow(Im1);
Im2=rgb2hsv(Im1);
Im3=rgb2ycbcr(Im1);
Figure, subplot(131);imshow(Im1);
Subplot(132);imshow(Im2);
Subplot(133);imshow(Im3);

1)resultat:
Extrait_comp
Code:
function [C1,C2,C3]= extrait_comp(matriceimage)
C1=matriceimage(:,:,1);
C2=matriceimage(:,:,2);
C3=matriceimage(:,:,3);
figure,
subplot(221);imshow(matriceimage);
subplot(222);imshow(C1);
subplot(223);imshow(C2);
subplot(224);imshow(C3);
End

Code exécution:
clc ; clear all; close all;
Im1=imread('D:\images2020\clown.bmp')
figure, imshow(Im1);
Im2=rgb2hsv(Im1);
figure, imshow(Im2);
Im3=rgb2ycbcr(Im1);
figure, imshow(Im3);
[C1,C2,C3]=extrait_comp(Im1);
[C1,C2,C3]=extrait_comp(Im2);
[C1,C2,C3]=extrait_comp(Im3);

Résultat

IV. Re-échantillonnage et quantification


Rééchantillonnage
Code:
Function Imse=sousechan(matriceimage)
[m n]=size(matriceimage);
Imse=matriceimage(1:2:m,1:2:n);
Figure,subplot(121);imshow(matriceimage);
subplot(122);imshow(Imse);
End
------------
clc ;clear all; close all;
Im1=imread ('D:\images2020\lena.bmp')
e2=sousechan(Im1);
Résultat

function [ech2,ech4]=sousechan1(im)
[m n]=size(im);
ech2=im(1:2:m,1:2:n);
ech4=im(1:2:m,1:2:n);
figure, subplot(131),imshow(im);
subplot(133),imshow(ech2);
subplot(133),imshow(ech4);
End
-----------
clc ;clear all; close all;
Im1=imread ('D:\images2020\lena.bmp')
[e2 e4]=sousechan1(Im1);

Résultat
Quantification
function [mq127,mq31,mq3,mq1]=quanti(Im1)
Im1=double(Im1);
mm=max(max(Im1));
mq127=round(Im1*127/mm);
mq31=round(Im1*31/mm);
mq3=round(Im1*3/mm);
mq1=round(Im1*1/mm);
figure,
subplot(151);imshow(Im1/255);
subplot(152);imshow(mq127/255);
subplot(153);imshow(mq31/255);
subplot(154);imshow(mq3/255);
subplot(155);imshow(mq1/255);
End
-----------
clc;clear all;close all;
Im1=imread('D:\images2020\clown.bmp')
[C1,C2,C3]=extrait_comp(Im1);
[iq127r,iq31r]=quanti(C1);
[iq127v,iq31v]=quanti(C2);
[iq127b,iq31b]=quanti(C3);
Im2(:,:,1)=iq127r;
Im2(:,:,2)=iq127v;
Im2(:,:,3)=iq127b;
Im3(:,:,1)=iq31r;
Im3(:,:,2)=iq31v;
Im3(:,:,3)=iq31b;
IM3=uint8(Im3);
IM2=uint8(Im2);
figure;
subplot(121);
imshow(IM2);
subplot(122);
imshow(IM3);

Résultat

You might also like