44 lines
1.1 KiB
Mathematica
44 lines
1.1 KiB
Mathematica
|
% Aymeric Arnould, Tom Colinot
|
||
|
% TP3
|
||
|
% Compensation de mouvement (1/2)
|
||
|
% Codage d'une séquence
|
||
|
|
||
|
clear all
|
||
|
|
||
|
n=5; %Nombre d'images à coder
|
||
|
gamma=1;
|
||
|
blksize = 16; %taille des blocs
|
||
|
SearchRange = 8; %portée des vecteurs mouvements
|
||
|
|
||
|
file = fopen('Foreman.qcif','r');
|
||
|
|
||
|
[compY,~,~]=yuv_readimage(file,'qcif');
|
||
|
Y= zeros(size(compY,1),size(compY,2),n); %images de base
|
||
|
Yc= zeros(size(compY,1),size(compY,2),n); %images (dé)codées
|
||
|
Yp= zeros(size(compY,1),size(compY,2),n); %images prédites
|
||
|
|
||
|
%Codage de la première image
|
||
|
[I_rec,PSNR,bpp] = encodeINTRA(compY,gamma);
|
||
|
Y(:,:,1) = compY;
|
||
|
Yc(:,:,1) = I_rec;
|
||
|
|
||
|
for k = 2:n
|
||
|
[compY,~,~]=yuv_readimage(file,'qcif');
|
||
|
Y(:,:,k) = compY;
|
||
|
compYr = Yc(:,:,k-1);
|
||
|
[compPred,~,~,~] = PicturePred(compY,compYr,blksize,SearchRange);
|
||
|
[I_rec,~,~] = encodeINTRA(compY-compPred,gamma);
|
||
|
|
||
|
Yc(:,:,k) = compPred + I_rec;
|
||
|
Yp(:,:,k) = compPred;
|
||
|
end
|
||
|
|
||
|
% Affichage des images de bases et des images codées de la séquence
|
||
|
figure(1)
|
||
|
colormap(gray)
|
||
|
for i=1:n
|
||
|
subplot(3,5,i); imagesc(Y(:,:,i));
|
||
|
subplot(3,5,i+n); imagesc(Yp(:,:,i));
|
||
|
subplot(3,5,i+2*n); imagesc(Y(:,:,i)-Yp(:,:,i));
|
||
|
end
|