-
Notifications
You must be signed in to change notification settings - Fork 1
/
Example_preprocess_and_calculate_performance.m
63 lines (46 loc) · 2.23 KB
/
Example_preprocess_and_calculate_performance.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
% Example of preprocessing for "Metrics_performance" function using
% Toyama database (Z. M. Parvez Sazzad, Y. Kawayoke, and Y. Horita.
% Image quality evaluation database. http://mict.eng.u-toyama.ac.jp/database_toyama/.)
%
% In case of any questions, contact Lukas Krasula (L.Krasula@gmail.com)
clear all; close all; clc;
load('util/Example_Toyama.mat')
% MOS - column vector of MOS values
% SD - column vector of respective standard deviations
% num_obs - column vector of number of observers that evaluated each stimulus
% psnr - column vector of PSNR values
% ssim - column vector of SSIM values
N = size(MOS,1);
metrics = {'psnr','ssim'};
%% calculate significance of differences according to ITU-T Rec. J.149
% Note that for data from indirect scaling experiment, the procedure will
% be different.
% The goal is to obtain a matrix "signif" as
% signif = 0 : pair is not significantly different
% -1 : first stimulus is statistically significantly worse
% 1 : first stimulus is statistically significantly better
d_mos = repmat(MOS,1,N) - repmat(MOS',N,1); % calculate MOS difference
d_mos = d_mos(~tril(ones(N))); % take elements above diagonal (we are not interested in self differences)
se_mos = sqrt( repmat(((SD.^2)./num_obs),1,N) + repmat(((SD.^2)./num_obs)',N,1));
se_mos = se_mos(~tril(ones(N)));
se_mos(se_mos == 0) = 1e-6; % to avoid division by zero;
z = d_mos./se_mos;
p_z = .5+erf(abs(z)/sqrt(2))/2;
signif = p_z;
signif(p_z<0.95) = 0;
signif(p_z>=0.95) = sign(d_mos(p_z>=0.95));
%% calculate the ObjScoDif (i.e. differences of objective scores)
objScoDif = [];
for m = 1:length(metrics)
eval(['OM = ' metrics{m} ';']) % read the metric values
d_om = repmat(OM,1,N) - repmat(OM',N,1);
objScoDif(:,m) = d_om(~tril(ones(N)));
SROCC(m) = corr(MOS,OM,'type','spearman');
KROCC(m) = corr(MOS,OM,'type','kendall');
end
% transposition, since the function requires signif to be a row vector
% see help Metrics_performance
signif = signif';
objScoDif = objScoDif';
%% Performance evaluation
results = Metrics_performance(objScoDif,signif,1);