-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathdistance2boundry.m
32 lines (23 loc) · 1.05 KB
/
distance2boundry.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
%% instruction
% This function is the auxiliary function for function
% <<calculate_confidence_mask>>, to get distance to the boundary
% in advance.
% For each point in the inpainting domain assigns the distance to the nearest point NOT belonging to
% the inpainting domain(amounts to the distance to the nearest point at the
% boundary)
% Here, we only care about the points inside the inpainting domain, so as for points outside
% inpainting domain, to facilitate the following implement, all assigned to 1
%%
function dist = distance2boundry(domain)
dist = 1 - domain;
se = strel('square', 3);
boundary = imdilate(domain, se) - domain;
[coordinate_bound(:, 1), coordinate_bound(:, 2), ~] = find(boundary);
[coordinate_dom(:, 1), coordinate_dom(:, 2), ~] = find(domain);
tmp = pdist2(coordinate_bound, coordinate_dom, 'Euclidean');
tmp = min(tmp);
for i = 1 : size(coordinate_dom(:, 1), 1)
dist(coordinate_dom(i, 1), coordinate_dom(i, 2)) = tmp(i);
end
dist = double(dist);
end