-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathaggregate_from_patches.m
45 lines (32 loc) · 1.77 KB
/
aggregate_from_patches.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
function [labels_mat, air_est, est_conf, inlier_fit_step] = ...
aggregate_from_patches(labels, nrow, ncol, patch_size, xrow, ycol, ...
air_est_col, est_conf_col, inlier_mask)
labels_mat = zeros(nrow, ncol);
air_est = zeros(nrow, ncol);
est_conf = zeros(nrow, ncol);
inlier_fit_step = zeros(nrow, ncol);
for ii=1:length(xrow)
row = xrow(ii);
col = ycol(ii);
air_est_patch = air_est(row:row+patch_size-1, col:col+patch_size-1);
air_est_patch_c = reshape(air_est_col(:, ii), patch_size, patch_size);
max_val = max(air_est_patch, air_est_patch_c);
update_mask = (max_val == air_est_patch_c); % these indices need update
air_est_patch(update_mask) = air_est_patch_c(update_mask);
air_est(row:row+patch_size-1, col:col+patch_size-1) = air_est_patch;
% corresponding confidence
est_conf_patch = est_conf(row:row+patch_size-1, col:col+patch_size-1);
est_conf_col_r = reshape(est_conf_col(:, ii), patch_size, patch_size);
est_conf_patch(update_mask) = est_conf_col_r(update_mask);
est_conf(row:row+patch_size-1, col:col+patch_size-1) = est_conf_patch;
% corresponding label
labels_mat_patch = labels_mat(row:row+patch_size-1, col:col+patch_size-1);
labels_mat_npatch = labels(ii)*ones(patch_size);
labels_mat_patch(update_mask) = labels_mat_npatch(update_mask);
labels_mat(row:row+patch_size -1, col:col+patch_size -1) = labels_mat_patch;
% inlier pixels from fit step
inlier_fit_step(row:row+patch_size-1, col:col+patch_size-1) = ...
max(inlier_fit_step(row:row+patch_size-1, col:col+patch_size-1), ...
reshape(inlier_mask(:, ii), patch_size, patch_size));
end
end