58 lines
1.6 KiB
Matlab
58 lines
1.6 KiB
Matlab
% Aymeric Arnould, Tom Colinot
|
|
% TP3
|
|
% Compensation de mouvement (2/2)
|
|
% PSNR moyen et débit moyen
|
|
|
|
%clear all
|
|
|
|
n=5; %Nombre d'images à coder
|
|
gamma=1:10;
|
|
blksize = 16; %taille des blocs
|
|
SearchRange = 8; %portée des vecteurs mouvements
|
|
|
|
PSNRmoy=[];
|
|
bpsmoy=[];
|
|
bpsmoy2=[];
|
|
|
|
for i=1:length(gamma)
|
|
g=gamma(i);
|
|
file = fopen('Foreman.qcif','r');
|
|
|
|
PSNR_seq=[];
|
|
bpp_seq=[];
|
|
bppMV_seq=[];
|
|
|
|
[compY,~,~]=yuv_readimage(file,'qcif');
|
|
Yc= zeros(size(compY,1),size(compY,2),n); %images (dé)codées
|
|
|
|
%Codage de la première image
|
|
[I_rec,PSNR,bpp] = encodeINTRA(compY,g);
|
|
Yc(:,:,1) = I_rec;
|
|
PSNR_seq(1) = PSNR;
|
|
bpp_seq(1) = bpp;
|
|
|
|
for k = 2:n
|
|
[compY,~,~]=yuv_readimage(file,'qcif');
|
|
compYr = Yc(:,:,k-1);
|
|
[compPred,~,~,bppMV] = PicturePred(compY,compYr,blksize,SearchRange);
|
|
[I_rec,~,bpp] = encodeINTRA(compY-compPred,g);
|
|
|
|
Yc(:,:,k) = compPred + I_rec;
|
|
|
|
PSNR_seq(k) = PSNR;
|
|
bpp_seq(k) = bpp;
|
|
bppMV_seq(k-1) = bppMV;
|
|
end
|
|
|
|
PSNRmoy(i) = mean(PSNR_seq);
|
|
bpsmoy(i) = mean(bpp_seq)*size(compY,1)*size(compY,2)*15; %en ne tenant pas compte de bppMV
|
|
bpsmoy2(i) = (mean(bppMV_seq)+mean(bpp_seq))*size(compY,1)*size(compY,2)*15; %en tenant compte de bppMV
|
|
|
|
fclose('all');
|
|
|
|
end
|
|
|
|
figure(2);
|
|
subplot(131); plot(gamma,PSNRmoy); xlabel('gamma'); ylabel('PSNR moyen');
|
|
subplot(132); plot(gamma,bpsmoy,gamma,bpsmoy2); xlabel('gamma'); ylabel('Debit moyen (bps)'); legend('Sans bppMV','Avec bppMV');
|
|
subplot(133); plot(bpsmoy,PSNRmoy,bpsmoy2,PSNRmoy); xlabel('Debit moyen (bps)'); ylabel('PSNR moyen'); legend('Sans bppMV','Avec bppMV');
|