-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest_ibc.m
More file actions
186 lines (148 loc) · 6.45 KB
/
test_ibc.m
File metadata and controls
186 lines (148 loc) · 6.45 KB
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
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
function test_ibc
% Image Batch Compare :: A command line program for comparing images between two directories that contain an identical number of TIF files (with matching filename pairs between the two) that meet a certain search criteria set in code.
%%%%%% MAKE CHANGES HERE %%%%%%
tifDir_1_name = 'Original PIL';
tifDir_2_name = 'New PIL';
tifFnameSearch = '*_bitmask.tif';
tifDir_1 = 'V:\pgc\data\elev\dem\setsm\klassen\region-2018jun13\tif_results\2m\bitmask_lsf_pil';
tifDir_2 = 'V:\pgc\data\elev\dem\setsm\klassen\region-2018jun13\tif_results\2m';
% tifDir_1 = 'D:\test_s2s\reg34_masks\matlab\';
% tifDir_2 = 'D:\test_s2s\reg34_masks\python\';
% tifDir_1 = 'V:\pgc\data\scratch\erik\test_s2s\PBS\region_31_alaska_south\tif_results\old_mask_sel\';
% tifDir_2 = 'V:\pgc\data\scratch\erik\test_s2s\PBS\region_31_alaska_south\tif_results\new_mask_sel\';
% tifDir_1 = 'V:\pgc\data\scratch\erik\test_s2s\matlab\setsm\REMA\region\region_01_subantarctic_islands\strips\8m';
% tifDir_2 = 'V:\pgc\data\scratch\erik\test_s2s\python\setsm\REMA\region\region_01_subantarctic_islands\strips\8m';
% tifDir_1 = 'V:\pgc\data\scratch\erik\test_s2s\matlab\setsm\ArcticDEM\region\region_02_greenland_southeast\tif_results\2m';
% tifDir_2 = 'V:\pgc\data\scratch\erik\test_s2s\python\setsm\ArcticDEM\region\region_02_greenland_southeast\tif_results\2m';
% tifDir_1 = 'C:\Users\husby036\Documents\Cprojects\test_s2s\region_02_greenland_southeast\matlab\tif_results\2m';
% tifDir_2 = 'C:\Users\husby036\Documents\Cprojects\test_s2s\region_02_greenland_southeast\python\tif_results\2m';
% tifDir_1 = 'C:/Users/husby036/Documents/Cprojects/test_s2s/russia_central_east/matlab/tif_results/2m';
% tifDir_2 = 'C:/Users/husby036/Documents/Cprojects/test_s2s/russia_central_east/python/tif_results/python_masks';
% tifDir_1 = 'C:/Users/husby036/Documents/Cprojects/test_s2s/russia_central_east/matlab/strips/2m';
% tifDir_2 = 'C:/Users/husby036/Documents/Cprojects/test_s2s/russia_central_east/python/strips/strips_pymask';
% tifDir_1 = 'C:/Users/husby036/Documents/Cprojects/test_s2s/subantarctic_islands/matlab/strips/strips2a';
% tifDir_2 = 'C:/Users/husby036/Documents/Cprojects/test_s2s/subantarctic_islands/python/strips/strips2a_matmask';
% tifDir_1 = 'C:/Users/husby036/Documents/Cprojects/test_s2s/subantarctic_islands/matlab/strips/strips2a';
% tifDir_2 = 'C:/Users/husby036/Documents/Cprojects/test_s2s/subantarctic_islands/python/strips/strips2a_pymask';
nodata_val = [];
% nodata_val = -9999;
mask_nans = true;
display_image = true;
display_histogram = true;
display_casting = false;
display_split = false;
display_difflate = false;
display_small = false;
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
compare = true;
if ~exist('tifDir_1', 'var') || isempty(tifDir_1)
compare = false;
if ~exist('tifDir_2', 'var') || isempty(tifDir_2)
error('No directories specified.');
end
tifDir_1 = tifDir_2;
tifDir_1_name = tifDir_2_name;
end
if ~exist('tifDir_2', 'var') || isempty(tifDir_2)
compare = false;
end
fprintf(2, ['' ...
'\n----- IBC COMMANDS -----\n' ...
'next (or empty command) :: Compare at current index.\n' ...
'rerun :: Redo comparison at previous index.\n' ...
'list :: Show indices of images for comparison.\n' ...
'figclose :: Close all figures.\n' ...
'quit :: Exit without closing figures.\n' ...
'close :: Close all figures and exit.\n']);
tifFiles_1 = dir([tifDir_1,'/',tifFnameSearch]);
tifFnames_1 = {tifFiles_1.name};
if compare
tifFiles_2 = dir([tifDir_2,'/',tifFnameSearch]);
tifFnames_2 = {tifFiles_2.name};
tifFnames = intersect(tifFnames_1, tifFnames_2);
tifFiles_1 = cellfun(@(x) [tifDir_1,'/',x], tifFnames, 'uniformoutput', false);
tifFiles_2 = cellfun(@(x) [tifDir_2,'/',x], tifFnames, 'uniformoutput', false);
else
tifFnames = tifFnames_1;
end
num_tifs = length(tifFnames);
digits = floor(log10(num_tifs)) + 1;
num_format = ['%-',num2str(digits),'d'];
if compare
fprintf('\n%s dir: %s\n', tifDir_1_name, tifDir_1);
fprintf( '%s dir: %s\n', tifDir_2_name, tifDir_2);
else
fprintf('\n%s dir: %s\n', tifDir_1_name, tifDir_1);
end
fprintf('Search string: %s\n', tifFnameSearch);
fprintf('\n%d tifs found:\n\n', num_tifs);
for i=1:num_tifs
fprintf([num_format,': %s\n'], i, char(tifFnames(i)));
end
fprintf('\n');
index = 0;
while (0 <= index) && (index <= num_tifs)
if index > 0
figtitle = char(tifFnames(index));
fprintf([num_format,': %s\n'], index, figtitle);
img_1 = char(tifFiles_1(index));
if compare
img_2 = char(tifFiles_2(index));
end
try
if compare
test_compareArrays(imread(img_1), imread(img_2), tifDir_1_name, tifDir_2_name, figtitle, nodata_val, mask_nans, display_image, display_histogram, display_casting, display_split, display_difflate, display_small);
else
test_compareImages(img_1, '', figtitle, 0, nodata_val, mask_nans, display_image, display_histogram, display_casting, display_split, display_difflate, display_small);
end
catch ME
if strcmp(ME.message, 'Input arrays for comparison differ in shape.')
fprintf('\n');
fprintf(2, ME.message);
fprintf('\n\n');
else
rethrow(ME);
end
end
end
last_index = index;
index = index + 1;
while true
fprintf(2, 'index = %d; IBC>> ', index);
if index > num_tifs
fprintf(2, '(end) ');
end
command = input('', 's');
if isempty(command)
close all;
break;
elseif strcmp(command, 'next')
break;
elseif strcmp(command, 'rerun')
index = last_index;
break;
elseif strcmp(command, 'list')
fprintf('\n');
for i=1:num_tifs
fprintf([num_format,': %s\n'], i, char(tifFnames(i)));
end
fprintf('\n');
elseif strcmp(command, 'figclose')
close all;
elseif strcmp(command, 'quit') || strcmp(command, 'close')
if strcmp(command, 'close')
close all;
end
index = inf;
break;
elseif ~isempty(command)
try
eval(command);
catch ME
fprintf(2, "\n%s\n\n", getReport(ME));
end
end
end
end
fprintf(2, '------------------------\n\n');
end