-
Notifications
You must be signed in to change notification settings - Fork 13
/
avg_error.m
executable file
·65 lines (58 loc) · 1.4 KB
/
avg_error.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
function [z F] = avg_error(Z, G);
% Z is our guess
% G is ground truth
% Parameters:
F = 0;
[nrows,ncols,d] = size(Z);
% rescale G (note that all images in this dataset have the same size):
GT = imresize(G, [nrows ncols]);
E = 0;
count = 0;
for i = 1:nrows
for j = 1:ncols
Z(i,j) = double(Z(i,j))/100;
if (Z(i,j) > 0)
% just to avoid divide-by-zeros
count = count+1;
if (GT(i,j) == 0)
GT(i,j) = 0.1;
end;
E = E + abs(double(Z(i,j))-GT(i,j))/GT(i,j);
F = F + double(Z(i,j))-GT(i,j);
end;
end;
end;
z = E/count;
return;
% $$$ % Z is our guess
% $$$ % G is ground truth
% $$$ F = 0;
% $$$
% $$$ s = size(Z);
% $$$ h = s(1);
% $$$ w = s(2);
% $$$
% $$$ %rescale G, since it has a funky dimension
% $$$ % note that all images in this dataset have the same size
% $$$ GT = imresize(G, s);
% $$$
% $$$
% $$$ E = 0;
% $$$ count = 0;
% $$$ for i = 1:h
% $$$ for j = 1:w
% $$$ Z(i,j) = double(Z(i,j))/100;
% $$$ if (Z(i,j) > 0)
% $$$
% $$$ % just to avoid divide-by-zeros
% $$$ count = count+1;
% $$$ if (GT(i,j) == 0)
% $$$ GT(i,j) = 0.1;
% $$$ end;
% $$$ E = E + abs(double(Z(i,j))-GT(i,j))/GT(i,j);
% $$$ F = F + double(Z(i,j))-GT(i,j);
% $$$ % E = E + abs(double(Z(i,j))-GT(i,j))/GT(i,j);
% $$$ end;
% $$$ end;
% $$$ end;
% $$$ z = E/count;