-
Notifications
You must be signed in to change notification settings - Fork 2
/
Get_Reconstruction_Coeff.m
67 lines (55 loc) · 1.98 KB
/
Get_Reconstruction_Coeff.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
function [H, neighborhood, neighborCoeff] = Get_Reconstruction_Coeff( pts, E )
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
% INPUT
% pts An N x 2 matrix which represents a N point-set
% E An N x N 0-1 edge matrix. The ith row records the ith
% point's neighbors
%
% OUTPUT
% H The N x N reconstruction matrix. H = I - W.
% Ideally, H * pts should be an N x 2 zero matrix.
% neighborhood An N x 1 cell vector. The ith element records the ith point's
% neighbors' indices.
% neighborCoeff An N x 1 cell vector. The ith element records the ith point's
% neighbors' reconstruction weights.
% trustRegion An Nm x 4 trust region matrix. The ith row records ith
% model point's trust region. Each row has a data
% structure like [x_min x_max y_min y_max]
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
[Nm, d] = size( pts );
neighborCoeff = cell( Nm, 1 );
neighborhood = cell( Nm, 1 );
for i = 1:Nm
neighborhood{i} = find( E(i,:) ~= 0 );
if length( neighborhood{i} ) < 1
error('E matrix illegal!\n The %dth point has at most 0 neighbors!\n', i);
end
end
% Calculate the convex combination
% H = I - W
H = sparse( Nm, Nm );
for i = 1:Nm
fprintf( 1, 'The %dth point.', i );
% current point
m = pts(i,:);
% all neighbors
n = pts( neighborhood{i}, : );
% number of three neighbors
nNum = length( neighborhood{i} );
% set up sum(w) = 1
A = ones( d+1, nNum );
% set up d rows to be points
A( 2:end, : ) = n';
% set up sum(w) = 1
b = ones( d+1, 1 );
% set up recovered points
b( 2:end ) = m;
w = lsqr( A, b, 1e-12, 10 );
neighborCoeff{i} = w;
%disp(w)
H( i, neighborhood{i} ) = -w;
H( i, i ) = 1;
end
%disp(H)
H = sparse(H);