

outputfile = 'formean';
filename = 'foreman.qcif';
endframe =48;
movietype=0;
Block_Size_x=8;
Block_Size_y=8;
Block_Size_t=1;
Support_XY_begin=-7;
Support_XY_end=8;
Support_t_begin=0;
StartSupport=16;




% 2D DCT 
PSNR_NoMC_2DDCT = [];
rate_NoMC_2DDCT = [];
for stepsize=[ 4 8 16 24 32 48 64 128],
    [Y_encoded, PSNR, rate ] = NoMC_2D_DCT(filename,endframe,movietype,Block_Size_x,Block_Size_y,Block_Size_t,Support_XY_begin,Support_XY_end, Support_t_begin,stepsize,outputfile,StartSupport);
    PSNR_NoMC_2DDCT = [PSNR_NoMC_2DDCT PSNR ];
    rate_NoMC_2DDCT = [rate_NoMC_2DDCT rate ];
    stepsize
    eval(['save ./RESULTS/results_NoMC_2DDCT_' outputfile ' PSNR_NoMC_2DDCT rate_NoMC_2DDCT']);
end


Block_Size_t=8;
% 3D DCT
PSNR_NoMC_3DDCT = [];
rate_NoMC_3DDCT = [];
for stepsize=[ 4 8 16 24 32 48 64 128],
    [Y_encoded, PSNR, rate ] = NoMC_3D_DCT(filename,endframe,movietype,Block_Size_x,Block_Size_y,Block_Size_t,Support_XY_begin,Support_XY_end, Support_t_begin,stepsize,outputfile,StartSupport);
    PSNR_NoMC_3DDCT = [PSNR_NoMC_3DDCT PSNR ];
    rate_NoMC_3DDCT = [rate_NoMC_3DDCT rate ];
    eval(['save ./RESULTS/results_NoMC_3DDCT_' outputfile ' PSNR_NoMC_3DDCT rate_NoMC_3DDCT']);
end


Block_Size_t=1;

% 2D [ 4 8 16 24 32 48 64 128]
PSNR_2DMC_2DDCT = [];
rate_2DMC_2DDCT = [];
for stepsize=[ 4 8 16 24 32 48 64 128],
    stepsize
    [Y_encoded, PSNR, rate ] = Block_MC_2D_DCT(filename,endframe,movietype,Block_Size_x,Block_Size_y,Block_Size_t,Support_XY_begin,Support_XY_end, Support_t_begin,stepsize,outputfile,StartSupport);
    PSNR_2DMC_2DDCT = [PSNR_2DMC_2DDCT PSNR ];
    rate_2DMC_2DDCT = [ rate_2DMC_2DDCT rate ];
    eval(['save ./RESULTS/results_2DMC_2DDCT_8_8_1_8_1' outputfile ' PSNR_2DMC_2DDCT rate_2DMC_2DDCT']);
end




% 3D MC
endframe=72;
Block_Size_t=6;
%outputfile = 'mthr_dotr_8_8_6_8_1';
Support_t_begin=0;

PSNR_3DMC_3DDCT_6 = [];
rate_3DMC_3DDCT_6 = [];
for stepsize=[ 4 8 16 24 32 48 64 128],
    stepsize
    [Y_encoded, PSNR, rate ] = Volume_MC_3D_DCT(filename,endframe,movietype,Block_Size_x,Block_Size_y,Block_Size_t,Support_XY_begin,Support_XY_end, Support_t_begin,stepsize,outputfile,StartSupport);
    PSNR_3DMC_3DDCT_6 = [PSNR_3DMC_3DDCT_6 PSNR ];
    rate_3DMC_3DDCT_6 = [ rate_3DMC_3DDCT_6 rate ];
 eval(['save ./RESULTS/results_3DMC_3DDCT_8_8_6_8_1' outputfile ' PSNR_3DMC_3DDCT_6 rate_3DMC_3DDCT_6']);  
end


Block_Size_t=8;
%outputfile = 'mthr_dotr_8_8_6_8_1';
Support_t_begin=0;

PSNR_3DMC_3DDCT_8 = [];
rate_3DMC_3DDCT_8 = [];
for stepsize=[ 4 8 16 24 32 48 64 128],
    stepsize
    [Y_encoded, PSNR, rate ] = Volume_MC_3D_DCT(filename,endframe,movietype,Block_Size_x,Block_Size_y,Block_Size_t,Support_XY_begin,Support_XY_end, Support_t_begin,stepsize,outputfile,StartSupport);
    PSNR_3DMC_3DDCT_8 = [PSNR_3DMC_3DDCT_8 PSNR ];
    rate_3DMC_3DDCT_8 = [ rate_3DMC_3DDCT_8 rate ];
 eval(['save ./RESULTS/results_3DMC_3DDCT_8_8_8_8_1' outputfile ' PSNR_3DMC_3DDCT_8 rate_3DMC_3DDCT_8']);  
end


Block_Size_t=4;
%outputfile = 'mthr_dotr_8_8_6_8_1';
Support_t_begin=0;

PSNR_3DMC_3DDCT_4 = [];
rate_3DMC_3DDCT_4 = [];
for stepsize=[ 4 8 16 24 32 48 64 128],
    stepsize
    [Y_encoded, PSNR, rate ] = Volume_MC_3D_DCT(filename,endframe,movietype,Block_Size_x,Block_Size_y,Block_Size_t,Support_XY_begin,Support_XY_end, Support_t_begin,stepsize,outputfile,StartSupport);
    PSNR_3DMC_3DDCT_4 = [PSNR_3DMC_3DDCT_4 PSNR ];
    rate_3DMC_3DDCT_4 = [ rate_3DMC_3DDCT_4 rate ];
 eval(['save ./RESULTS/results_3DMC_3DDCT_8_8_4_8_1' outputfile ' PSNR_3DMC_3DDCT_4 rate_3DMC_3DDCT_4']);  
end


Block_Size_t=4;
%outputfile = 'mthr_dotr_8_8_6_8_1';
Support_t_begin=0;

PSNR_3DMC_3DDCT_STD_4 = [];
rate_3DMC_3DDCT_STD_4 = [];
for stepsize=[ 4 8 16 24 48 64 128],
    stepsize
    [Y_encoded, PSNR, rate ] = Volume_MC_3D_DCT_STD(filename,endframe,movietype,Block_Size_x,Block_Size_y,Block_Size_t,Support_XY_begin,Support_XY_end, Support_t_begin,stepsize,outputfile,StartSupport);
    PSNR_3DMC_3DDCT_STD_4 = [PSNR_3DMC_3DDCT_STD_4 PSNR ]
    rate_3DMC_3DDCT_STD_4 = [ rate_3DMC_3DDCT_STD_4 rate ]
 eval(['save results_3DMC_3DDCT__STD_8_8_4_8_1' outputfile ' PSNR_3DMC_3DDCT_STD_4 rate_3DMC_3DDCT_STD_4']);  
end

Support_t_begin=0;
numberofPCAcoefs=5;
PCAcoefsstepsize=6;
Block_Size_t=8;
PSNR_3DMC_3DDCT_STD_4 = [];
rate_3DMC_3DDCT_STD_4 = [];
stepsize=[ 4 8 16 32 64 128];
[Y_encoded, PSNR_NoMC_3DDCT_PCA, rate_NoMC_3DDCT_PCA ] = NoMC_3D_PCA_DCT(stepsize,numberofPCAcoefs,PCAcoefsstepsize,filename,endframe,movietype,Block_Size_x,Block_Size_y,Block_Size_t,Support_XY_begin,Support_XY_end, Support_t_begin,stepsize,outputfile,StartSupport);
eval(['save results_NoMC_3DDCT_PCA_8_8_8_5_6' outputfile ' PSNR_NoMC_3DDCT_PCA rate_NoMC_3DDCT_PCA']);  





% plot the results

cd RESULTS

eval(['load results_NoMC_2DDCT_' outputfile ]);
eval(['load results_NoMC_3DDCT_' outputfile ]);
eval(['load results_2DMC_2DDCT_8_8_1_8_1' outputfile ]);
%eval(['load results_3DMC_3DDCT_8_8_6_8_1' outputfile ]);
%eval(['load results_3DMC_3DDCT_8_8_8_8_1' outputfile ]);
eval(['load results_3DMC_3DDCT_8_8_4_8_1' outputfile ]);
eval(['load results_3DMC_3DDCT_STD_8_8_4_8_1' outputfile ]);


cd ..


plot(rate_NoMC_2DDCT, PSNR_NoMC_2DDCT, 'k.-',rate_NoMC_3DDCT, PSNR_NoMC_3DDCT, 'k.:',rate_2DMC_2DDCT, PSNR_2DMC_2DDCT, 'b.-', rate_3DMC_3DDCT_STD_4, PSNR_3DMC_3DDCT_STD_4, 'co--'); %,rate_NoMC_3DDCT_PCA,PSNR_NoMC_3DDCT_PCA,'r.-',rate_2DMC_2DDCT, PSNR_2DMC_2DDCT, 'b.-', rate_3DMC_3DDCT_4, PSNR_3DMC_3DDCT_4, 'co--');
legend('2D DCT', '3D DCT', '2D MC', '3D MC - STD');%'3D DCT - PCA','2D MC', '3D MC - 4');
xlabel('Rate (bits per pixel)');
ylabel('PSNR');
title([outputfile]);

hold on;
plot(rate_NoMC_3DDCT_PCA,PSNR_NoMC_3DDCT_PCA,'r.-');
