clc ;
clear ;
index = 1 ;
load input_box ;
v1_img = round(view1_img*204) ; 
v2_img = round(view2_img*204) ; 

gap = zeros(size(v1_img,1),20) ;
img = [v1_img gap v1_img] ;
frame(:,:,1) = img ; frame(:,:,2) = ones(size(img))*128 ; frame(:,:,3) = ones(size(img))*128 ;
frame_rgb = ycbcr2rgb(frame/255);
M(index)=im2frame(frame_rgb);
index = index + 1 ;
for i = 1 : 3
    s = ['load output' num2str(i)] ;
    eval(s) ;
    from1and2 = round(novel_view_from1and2*204) ;
    img = [v1_img gap from1and2] ;
    frame(:,:,1) = img ; frame(:,:,2) = ones(size(img))*128 ; frame(:,:,3) = ones(size(img))*128 ;
    frame_rgb = ycbcr2rgb(frame/255);
    M(index)=im2frame(frame_rgb);
    index = index + 1 ;
    M(index)=im2frame(frame_rgb);
    index = index + 1 ;
end
load output4 ;
from1and2 = round(novel_view_from1and2*204) ;
img = [v1_img gap from1and2] ;
frame(:,:,1) = img ; frame(:,:,2) = ones(size(img))*128 ; frame(:,:,3) = ones(size(img))*128 ;
frame_rgb = ycbcr2rgb(frame/255);
M(index)=im2frame(frame_rgb);
index = index + 1 ;
img = [v2_img gap from1and2] ;
frame(:,:,1) = img ; frame(:,:,2) = ones(size(img))*128 ; frame(:,:,3) = ones(size(img))*128 ;
frame_rgb = ycbcr2rgb(frame/255);
M(index)=im2frame(frame_rgb);
index = index + 1 ;
for i = 5 : 7
    s = ['load output' num2str(i)] ;
    eval(s) ;
    from1and2 = round(novel_view_from1and2*204) ;
    img = [v2_img gap from1and2] ;
    frame(:,:,1) = img ; frame(:,:,2) = ones(size(img))*128 ; frame(:,:,3) = ones(size(img))*128 ;
    frame_rgb = ycbcr2rgb(frame/255);
    M(index)=im2frame(frame_rgb);
    index = index + 1 ;
    M(index)=im2frame(frame_rgb);
    index = index + 1 ;
end
img = [v2_img gap v2_img] ;
frame(:,:,1) = img ; frame(:,:,2) = ones(size(img))*128 ; frame(:,:,3) = ones(size(img))*128 ;
frame_rgb = ycbcr2rgb(frame/255);
M(index)=im2frame(frame_rgb);
   
avi_filename = 'cartoon_fps8.avi' ;
movie2avi(M, avi_filename, 'compression', 'none', 'fps',8);
avi_filename = 'cartoon_fps1.avi' ;
movie2avi(M, avi_filename, 'compression', 'none', 'fps',1);
avi_filename = 'cartoon_fps10.avi' ;
movie2avi(M, avi_filename, 'compression', 'none', 'fps',10);
avi_filename = 'cartoon_fps12.avi' ;
movie2avi(M, avi_filename, 'compression', 'none', 'fps',12);
