-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathevaluate_results_dirs_linux.m
58 lines (51 loc) · 2.27 KB
/
evaluate_results_dirs_linux.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
function evaluate_results_dirs(input_dir,GT_dir,shave_width,verbose)
%% Parameters
% Directory with your results
%%% Make sure the file names are as exactly %%%
%%% as the original ground truth images %%%
% input_dir = fullfile(pwd,'your_results');
% Directory with ground truth images
% GT_dir = fullfile(pwd,'self_validation_HR');
% Number of pixels to shave off image borders when calcualting scores
% shave_width = 2;
% Set verbose option
% verbose = true;
addpath utils
input_dir_SR = dir([input_dir, '/visualization']);
for kk = 1:size(input_dir_SR, 1)
if length(input_dir_SR(kk).name) >= 10
%% Make SRdir and HRdir
SR_dir_name = input_dir_SR(kk).name;
gt_name = strsplit(input_dir_SR(kk).name, '_');
HR_dir_name = char(gt_name(1));
SR_dir = fullfile(input_dir, 'visualization', SR_dir_name);
HR_dir = fullfile(GT_dir, HR_dir_name, 'GTmod12');
addpath(SR_dir)
addpath(HR_dir)
%% Calculate scores and save
scores = calc_scores(SR_dir, HR_dir, str2num(shave_width), verbose);
%% Printing results
% perceptual_score = (mean([scores.NIQE]) + (10 - mean([scores.Ma]))) / 2;
% fprintf(['\n\nYour perceptual score is: ',num2str(perceptual_score)]);
% fprintf(['\nYour RMSE is: ',num2str(sqrt(mean([scores.MSE]))),'\n']);
%% Rename
for ii = 1:size(scores, 2)
oldname = scores(ii).name;
newname1 = oldname(1:end-4);
newname3 = oldname(end-3:end);
newname2 = ['_', num2str(scores(ii).NIQE), ...
'_', num2str(scores(ii).Ma), ...
'_', num2str(scores(ii).PI)];
newname = [newname1, newname2, newname3];
oldname2 = fullfile(SR_dir, scores(ii).name);
newname4 = fullfile(SR_dir, newname);
eval(['!mv',' "',oldname2,'" ',newname4])
end
foldername2 = ['_', num2str(mean([scores.NIQE])), ...
'_', num2str(mean([scores.Ma])), ...
'_', num2str(mean([scores.PI]))];
new_SR_dir_name = [SR_dir_name, foldername2];
eval(['!mv',' "',fullfile(input_dir, 'visualization', SR_dir_name), ...
'" ',fullfile(input_dir, 'visualization', new_SR_dir_name)])
end
end