clear
clc


dir='C:\Documents and Settings\ruigangfang\My Documents\MATLAB\3d\database\livephase2\Phase2';
load ([dir,'\3DDmosRelease.mat'])


[mm,nn]=size(Dmos);

dir_save='C:\Documents and Settings\ruigangfang\My Documents\MATLAB\3d\disparity_method4\data\phase2';
load ([dir_save,'\cyclopean_image\index.mat']);
%dir_save=[dir_save,'\cyclopean_image\'];

%dir_save=[dir_save,'\disparity_similarity_L\'];
%dir_save=[dir_save,'\disparity_similarity_R\'];
%dir_save=[dir_save,'\weight\'];

num=[];
% type=[4] ;% 0: noise, 1: jpeg2k, 2: jpeg, 3: gaussian blur, 4: fast-fading
% for i=1:max(size(type))
%     tt=[1:9]+9*type(i);%% [4 7 9]
%     tt=[tt,45+tt,2*45+tt,3*45+tt,4*45+tt,5*45+tt,6*45+tt,7*45+tt];
%     num=[num,tt];
% end
%%
num=[4]+9*4;
%%
%num=45
k=2;

for i=1:max(size(num))
    i/max(size(num))
    %% for cyclopean image read
    load ([dir_save,'\cyclopean_image\',num2str(num(i)),'.mat']);
    %% for img_l and img_r
    img=imread([dir,'\Stimuli\',StiFilename{num(i)}]);
    [m,n,t]=size(img);
    img_l=img(:,1:n/2,:);
    img_r=img(:,n/2+1:n,:);
    %% for dis_l and dis_r and  similarity
    load ([dir_save,'\disparity_similarity_L\',num2str(num(i)),'.mat']);
    dis_l=data{1};
    
    [gl_x gl_y]=gradient(dis_l);
    
    maxs=max(max(dis_l));
    mins=min(min(dis_l));
    depth_l=(dis_l+25)/50*255;
    
    ss2_l=data{2};
    ss3_l=data{3};
    ss4_l=data{4};
    clear data
    
    
    load ([dir_save,'\disparity_similarity_R\',num2str(num(i)),'.mat']);
    dis_r=data{1};
    
    [gr_x gr_y]=gradient(dis_r);
    
    maxs=max(max(dis_r));
    mins=min(min(dis_r));
    depth_r=(dis_r+25)/50*255;
    
    ss2_r=data{2};
    ss3_r=data{3};
    ss4_r=data{4};
    clear data
    if index==1
        depth=depth_l;
        gx=gl_x;
        gy=gl_y;
    else
        depth=depth_r;
        gx=gr_x;
        gy=gr_y;
    end
    g=gy;
     maxs=max(max(g));
    mins=min(min(g));
    g=(g-mins)/(maxs-mins)*256;
    %% for weight
    load ([dir_save,'\weight\',num2str(num(i)),'.mat']);
    %%
    
%    ss=rivalry(ss2_l,ss2_r,index);
    %subplot(3,3,k)
    figure(k)
    k=k+1;
    %hist(ss(:),[0:0.01:1])
    imshow(uint8(depth))
    xlabel([num2str(Dmos(num(i))),'   ',num2str(mean2(weight))]);
    %%
    score(i)=Dmos(num(i));
    
end
% figure(1)
% imshow(image)













