-
Notifications
You must be signed in to change notification settings - Fork 3
/
compute_datacost2.m
49 lines (46 loc) · 1.5 KB
/
compute_datacost2.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
% Create data cost matrix
%
%
%
%
%
%
%
%
% Juheon Lee 30/04/2016
function [wcost] = compute_datacost2(data,h1)
N = size(data,1);
cc = zeros(length(data),1);
for i= 1:N,
val = data(i,:);
HH = max(data(:,3));
r = exp((50-(HH-val(1,3)))/34);
[idx,~] = rangesearch(data(:,1:2),val(1,1:2),r);
j = idx{1};
height = data(j,:);
% x,y features
if length(height)>250
k = height(:,3)>val(1,3); height(k,:) = [];
h2z = histogram(height(:,3),15,'Normalization','probability'); h2 = h2z.Values;% x,y direction
%[~,h2y] = hist(height(:,2)-data(i,2),10); %h2y = h2y/max(h2y);
%[~,h2x] = hist(height(:,1)-data(i,1),10); %h2x = h2x/max(h2x);
%h2 = [h2z;h2y;h2x];
c = wasserstein(h1',h2');%*(34/(val(1,3)*0.75)));
if isempty(c)
c = 5;
end
cc(i) = c;
else
k = height(:,3)>val(1,3)+4; height(k,:) = [];
h2z = histogram(height(:,3),15,'Normalization','probability'); h2 = h2z.Values;% x,y direction
%[~,h2y] = hist(height(:,2)-data(i,2),10); %h2y = h2y/max(h2y);
%[~,h2x] = hist(height(:,1)-data(i,1),10); %h2x = h2x/max(h2x);
%h2 = [h2z;h2y;h2x];
c = wasserstein(h1',h2');%*(34/(val(1,3)*0.75)));
if isempty(c)
c = 5;
end
cc(i) = c;
end
end
wcost = cc;