-
Notifications
You must be signed in to change notification settings - Fork 8
/
testdata.m
151 lines (107 loc) · 3.13 KB
/
testdata.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
% This script is meant to be run LOCALLY.
%
% It down-samples the datasets produced by MATLAB script "importdata", thus
% producing the LR input data for both my SR algorithm and COCOLIB-6.
%
% Note that the 2 folders "hci" and "stanford", produced by IMPORTDATA must
% be stored inside folder pathIn defined below.
clear;
close all;
clc;
% ==== Test parameters ====================================================
% HCI = 1 creates HCI LR data, HCI = 0 does not. The same for STF.
HCI = 1;
STF = 0;
% Down sampling factor.
factor = 2;
% Gaussian noise standard deviation.
sigmaNoise = 0.0;
% Initializes the seed for random number generation.
rng(0);
% Input/output paths.
pathIn = '/Users/mattiarossi/Documents/MATLAB/LFdatasets/';
pathOut = '/Users/mattiarossi/Documents/MATLAB/superdata/';
fprintf('SUB SAMPLING FACTOR IS %d\n', factor);
% ==== HCI dataset ========================================================
% Light field names.
if HCI
fprintf('\nHCI dataset:\n');
list = { ...
'buddha', ...
'buddha2', ...
'couple' ...
'cube', ...
'horses', ...
'maria' ...
'medieval', ...
'mona', ...
'papillon', ...
'pyramide', ...
'statue', ...
'stillLife' ...
};
else
list = {};
end
% Full input path.
pathInFull = [pathIn, 'hci/'];
% Full output path.
pathOutFull = [pathOut, 'hci', num2str(factor), '/'];
mkdir(pathOutFull);
% Down-samples each light field.
for k = 1:1:length(list)
% Current light field name.
name = list{k};
fprintf('Sub sampling the light field %s.\n', name);
% Loads the light field.
aux = load([pathInFull, name, '.mat']);
Z = aux.Z;
clear('aux');
% Sub samples the light field and adds random noise.
[ZLR, ZHR] = high2low(Z, factor, sigmaNoise);
% Saves the HR and LR light fields.
save([pathOutFull, name, '.mat'], 'ZHR', 'ZLR');
% Frees memory.
clear('ZLR', 'ZHR');
end
% ==== STANFORD dataset ===================================================
% Light field names.
if STF
fprintf('\nSTANFORD dataset:\n');
list = { ...
'amethyst', ...
'beans', ...
'bracelet', ...
'bulldozer', ...
'bunny', ...
'cardsS', ...
'chess', ...
'eucalyptus', ...
'knights', ...
'treasure', ...
'truck' ...
};
else
list = {};
end
% Full input path.
pathInFull = [pathIn, 'stanford/'];
% Full output path.
pathOutFull = [pathOut, 'stanford', num2str(factor), '/'];
mkdir(pathOutFull);
% Down-samples each light field.
for k = 1:1:length(list)
% Current light field name.
name = list{k};
fprintf('Sub sampling the light field %s.\n', name);
% Loads the light field.
aux = load([pathInFull, name, '.mat']);
Z = aux.Z;
clear('aux');
% Sub samples the light field.
[ZLR, ZHR] = high2low(Z, factor, sigmaNoise);
% Saves the HR and LR light fields.
save([pathOutFull, name, '.mat'], 'ZHR', 'ZLR');
% Frees memory.
clear('ZLR', 'ZHR');
end