This repository has been archived by the owner on Feb 22, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathmslMainPoolingMULTI.m
164 lines (131 loc) · 4.79 KB
/
mslMainPoolingMULTI.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
function mslMainPoolingMULTI(poolInd, metInd, paramIndArray,blockSize)
%%
poolingCounter=1;%size(paramIndArray,2);
nDist=2;
nMetric=poolingCounter;
numCorr=3;
corrMat=zeros(numCorr,nMetric,nDist);
rmseMat=zeros(nMetric,nDist);
corrMatOrg=zeros(numCorr,nMetric,nDist);
corrType='Pearson';
corrType2='Spearman';
corrType3='Kendall';
dataDir=['../../databases',filesep,'live_multi'];
for kk=1:poolingCounter
paramInd=paramIndArray(kk);
imgDir=[dataDir,filesep,'Part 1'];
load([imgDir,filesep,'Imagelists.mat']);
load([imgDir,filesep,'Scores.mat']);
n=size(distimgs,1);
counter=0;
for ii=1:n
% ii
counter=counter+1;
I=imread([imgDir,filesep,'blurjpeg',filesep,distimgs{ii}]);
I2=imread([imgDir,filesep,'blurjpeg',filesep,refimgs{ref4dist(ii)}]);
gt(counter)=DMOSscores(ii);
b(counter)=mslPoolingMetric(I2, I,metInd,poolInd,paramInd,blockSize);
end
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
y=gt(1:225)';
len=size(y,1);
linX=1:len; linX=(linX/max(linX))*max(y);
linY=linX;
modelFun=@(b,x) b(1).*((1/2)-1./(1+exp(b(2).*(x-b(3)))))+b(4).*x+b(5);
x=abs(b');
x=x(1:225);
x(isnan(x))=0;
x(isinf(x))=0;
temp=x;
cInd=1;
rInd=kk;
% start=[0.0,0.1,0.0,0.0,0.0]';
% nlmColDist=fitnlm(x,y,modelFun,start);
% temp=predict(nlmColDist,x);
temp=x;
corrMat(1,rInd,cInd)=corr(temp,y,'Type',corrType);
corrMat(2,rInd,cInd)=corr(temp,y,'Type',corrType2);
corrMat(3,rInd,cInd)=corr(temp,y,'Type',corrType3);
rmseMat(rInd,cInd)=sqrt(mean((temp-y).^2));
corrMatOrg(1,rInd,cInd)=corr(x,y,'Type',corrType);
corrMatOrg(2,rInd,cInd)=corr(x,y,'Type',corrType2);
corrMatOrg(3,rInd,cInd)=corr(x,y,'Type',corrType3);
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
imgDir=[dataDir,filesep,'Part 2'];
load([imgDir,filesep,'Imagelists.mat']);
load([imgDir,filesep,'Scores.mat']);
n=size(distimgs,1);
for jj=1:n
% jj
counter=counter+1;
I=imread([imgDir,filesep,'blurnoise',filesep,distimgs{jj}]);
I2=imread([imgDir,filesep,'blurnoise',filesep,refimgs{ref4dist(jj)}]);
gt(counter)=DMOSscores(jj);
b(counter)=mslPoolingMetric(I2, I,metInd,poolInd,paramInd,blockSize);
end
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
y=gt(226:450)';
len=size(y,1);
linX=1:len; linX=(linX/max(linX))*max(y);
linY=linX;
modelFun=@(b,x) b(1).*((1/2)-1./(1+exp(b(2).*(x-b(3)))))+b(4).*x+b(5);
x=abs(b');
x=x(226:450);
x(isnan(x))=0;
x(isinf(x))=0;
temp=x;
cInd=2;
rInd=kk;
% start=[0.0,0.1,0.0,0.0,0.0]';
% nlmColDist=fitnlm(x,y,modelFun,start);
% temp=predict(nlmColDist,x);
temp=abs(x);
x = abs(x);
corrMat(1,rInd,cInd)=corr(temp,y,'Type',corrType);
corrMat(2,rInd,cInd)=corr(temp,y,'Type',corrType2);
corrMat(3,rInd,cInd)=corr(temp,y,'Type',corrType3);
rmseMat(rInd,cInd)=sqrt(mean((temp-y).^2));
corrMatOrg(1,rInd,cInd)=corr(x,y,'Type',corrType);
corrMatOrg(2,rInd,cInd)=corr(x,y,'Type',corrType2);
corrMatOrg(3,rInd,cInd)=corr(x,y,'Type',corrType3);
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
y=gt';
len=size(y,1);
linX=1:len; linX=(linX/max(linX))*max(y);
linY=linX;
modelFun=@(b,x) b(1).*((1/2)-1./(1+exp(b(2).*(x-b(3)))))+b(4).*x+b(5);
x=abs(b');
x(isnan(x))=0;
x(isinf(x))=0;
temp=x;
fileName2=['Multi_metric_','metInd_',num2str(metInd),'_','poolInd_',num2str(poolInd),'.txt'];
save(fileName2, 'temp', '-ASCII');
fileName=['data_T/Multi_metric_','metInd_',num2str(metInd),'_','poolInd_',num2str(poolInd),'.mat'];
save(fileName,'temp')
fileName=['Multi_GT','.mat'];
save(fileName,'y')
cInd=3;
rInd=kk;
% start=[0.0,0.1,0.0,0.0,0.0]';
% nlmColDist=fitnlm(x,y,modelFun,start);
% temp=predict(nlmColDist,x);
temp=x;
corrMat(1,rInd,cInd)=corr(temp,y,'Type',corrType);
corrMat(2,rInd,cInd)=corr(temp,y,'Type',corrType2);
corrMat(3,rInd,cInd)=corr(temp,y,'Type',corrType3);
rmseMat(rInd,cInd)=sqrt(mean((temp-y).^2));
corrMatOrg(1,rInd,cInd)=corr(x,y,'Type',corrType);
corrMatOrg(2,rInd,cInd)=corr(x,y,'Type',corrType2);
corrMatOrg(3,rInd,cInd)=corr(x,y,'Type',corrType3);
%%
end
%fileName=['Multi_corrAfter_','metInd_',num2str(metInd),'_','poolInd_',num2str(poolInd),'_paramInds_',num2str(paramIndArray),'_blockSize',num2str(blockSize),'.mat'];
fileName=['Multi_corrAfter_','metInd_',num2str(metInd),'_','poolInd_',num2str(poolInd),'.mat'];
save(fileName,'corrMat')
%fileName=['Multi_corrBefore_','metInd_',num2str(metInd),'_','poolInd_',num2str(poolInd),'_paramInds_',num2str(paramIndArray),'_blockSize',num2str(blockSize),'.mat'];
fileName=['Multi_corrBefore_','metInd_',num2str(metInd),'_','poolInd_',num2str(poolInd),'.mat'];
save(fileName,'corrMatOrg')
%fileName=['Multi_rmse_','metInd_',num2str(metInd),'_','poolInd_',num2str(poolInd),'_paramInds_',num2str(paramIndArray),'_blockSize',num2str(blockSize),'.mat'];
fileName=['Multi_rmse_','metInd_',num2str(metInd),'_','poolInd_',num2str(poolInd),'.mat'];
save(fileName,'rmseMat')
end