-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathnomalize.asv
111 lines (85 loc) · 2.08 KB
/
nomalize.asv
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
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
if 0
t = points(10, 3, :);
t = reshape(t, [111 111]);
for i = 1:7
i
row = t(i,:);
plot(row)
drawnow;
pause(0.1)
end
t2 = pointsNorm(10, 3, :);
t2 = reshape(t2, [111 111]);
row2 = t2(i,:);
figure(1);
clf reset;
colormap gray;
subplot(2, 1, 1);
plot(row, 'k')
xlabel('x von 1. Kamera')
ylabel('x von 2. Kamera')
subplot(2, 1, 2);
plot(row2, 'k')
xlabel('x von 1. Kamera')
ylabel('x von 2. Kamera')
return;
end
pointsNorm = points;
sortBase = zeros(size(pointsNorm, 2), size(pointsNorm, 3));
index2sort = sortBase;
sort2index = sortBase;
xList = points(1, 1, :);
xList = squeeze(xList);
yList = points(1, 2, :);
yList = squeeze(yList);
sortBase(3, :) = xList * max(yList) + yList;
sortBase(4, :) = yList * max(xList) + xList;
for i = 1:size(sortBase, 1)
[~, indices] = sort(sortBase(i, :));
index2sort(i, :) = squeeze(indices);
[~, indices] = sort(index2sort(i, :));
sort2index(i, :) = squeeze(indices);
end
if 0
for i = 1:size(pointsNorm, 1)
for index = 3:4
z = points(i, index, :);
z = squeeze(z);
z = z(index2sort(index, :));
x = 1:size(z);
mask = (isnan(z));
z1 = z;
z1(mask) = [];
x1 = x;
x1(mask) = [];
p = polyfit(x1', z1, 1);
zTrend = polyval(p, x');
zNorm = z - zTrend;
diff = 2*std(zNorm);
mask = abzNorm < diff;
zNorm = interp1(x1, z1, x, 'linear', 'extrap');
pointsNorm(i, index, :) = zNorm(sort2index(index, :));
end
end
%return;
end
pointsNorm2 = points;
for i = 1:size(pointsNorm2, 1)
for index = 3:4
z = points(i, index, :);
z = squeeze(z);
z = z(index2sort(index, :));
z1 = z;
x = 1:size(z);
mask = (isnan(z));
z1(mask) = [];
x1 = x;
x1(mask) = [];
p = polyfit(x1', z1, 1);
zTrend = polyval(p, x');
zNorm = z - zTrend;
plot(z);
return
pointsNorm2(i, index, :) = zNorm;
end
end