% Aymeric Arnould, Tom Colinot
% TP3
% Codage INTRA (2/3)
% Question 7 - PSNR moyen en fonction du débit moyen

%clear all;
PSNRmoy=[];
bpsmoy=[];
gamma=1:10;


for k=1:size(gamma,2)
    g=gamma(k);
    file = fopen('Foreman.qcif','r');

    PSNR=[];
    bpp=[];

    for i=1:5
        [compY,~,~]=yuv_readimage(file,'qcif');
        [~,b,r] = encodeINTRA(compY,g);
        PSNR(i)=b;
        bpp(i) = r;
    end

    PSNRmoy(k)=mean(PSNR);
    bpsmoy(k)=mean(bpp)*size(compY,1)*size(compY,2)*15;
end

figure(1)
subplot(131); plot(gamma,PSNRmoy); xlabel('gamma'); ylabel('PSNR moyen');
subplot(132); plot(gamma,bpsmoy); xlabel('gamma'); ylabel('Debit moyen (bps)');
subplot(133); plot(bpsmoy,PSNRmoy); xlabel('Debit moyen (bps)'); ylabel('PSNR moyen');