-
Notifications
You must be signed in to change notification settings - Fork 1
/
perform_edge_reconstruction.m
86 lines (72 loc) · 1.63 KB
/
perform_edge_reconstruction.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
function M = perform_edge_reconstruction(Param, options)
% M = perform_edge_reconstruction(Param, options);
options.null = 0;
if isfield(options, 'w')
w = options.w;
else
w = 11;
end
if isfield(options, 'manifold_type')
manifold_type = options.manifold_type;
else
manifold_type = 'edges';
end
if isfield(options, 'sigma')
sigma = options.sigma;
else
sigma = 0.1;
end
sigma = sigma*w;
Delta = Param.Delta;
if strcmp(manifold_type, 'edges')
M = tanh(Delta/sigma);
else
M = 2*( 1 - exp( -Delta.^2 / (2*sigma^2) ) ) - 1;
end
return;
Theta = Param.Theta;
if isfield(Param, 'Lambda')
Lambda = Param.Lambda;
else
Lambda = Delta*0+1;
end
if isfield(Param, 'Mu')
Mu = Param.Mu;
else
Mu = Delta*0;
end
n = size(Theta,1);
if isfield(options, 'n_full')
n_full = options.n_delta;
else
n_delta = 16;
end
if isfield(options, 'n_theta')
n_theta = options.n_theta;
else
n_theta = 24;
end
s = w^2;
options.rescale = 0;
options.add_flat = 1;
[H,delta_list,theta_list] = compute_edge_patches(w,options);
M = zeros(n);
for i=1:n
for j=1:n
% distance on circle
t = Theta(i,j);
d = Delta(i,j);
if d==Inf
M(i,j) = -1;
elseif d==-Inf
M(i,j) = 1;
else
Et = min([abs(theta_list-t), abs(theta_list-t+2*pi), abs(theta_list-t-2*pi)], [], 2);
E = abs(delta_list-d) + Et;
[tmp,I] = min(E);
x = H(:,:,I);
x = x((w+1)/2,(w+1)/2);
M(i,j) = x*Lambda(i,j)+Mu(i,j);
end
end
end