clear
clc

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

dir1='C:\Documents and Settings\ruigangfang\My Documents\MATLAB\3d\disparity_method4\data\phase2\';

% for i=1:360 
%     i
%     load(['C:\Documents and Settings\ruigangfang\My Documents\MATLAB\3d\disparity_method4\data\phase2\cyclopean_image\',num2str(i),'.mat']);
%     score(i)=brisquescore(image);
% end

load ([dir1,'cyclopean_image\index']);

num=[];
type=[0] ;% 0: noise, 1: jpeg2k, 2: jpeg, 3: gaussian blur, 4: fast-fading
for i=1:max(size(type))
    tt=[1:9]+9*type(i);
    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

for i=1:max(size(num))
    i
    load ([dir1,'weight\',num2str(num(i)),'.mat']);
    w=mean2(weight);
    img=imread([dir,'\Stimuli\',StiFilename{num(i)}]);
    [m,n,t]=size(img);
    imgl=img(:,1:n/2,:);
    imgr=img(:,n/2+1:n,:);
    scorel=brisquescore(imgl);
    scorer=brisquescore(imgr);
%     if index(i)==1
%         score(i)=scorel*w+scorer*(1-w);
%     else
%         score(i)=scorer*w+scorel*(1-w);
%     end
score(i)=scorel+scorer;
std(i)=Dmos(num(i));
end

corr(score',std','type','spearman')