-
Notifications
You must be signed in to change notification settings - Fork 0
/
mask_image.m
63 lines (46 loc) · 1.24 KB
/
mask_image.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
function [ listRes, imgDim ] = mask_image( listXYZ )
% Liefert die Koordinaten des Bildes.
% Schneidet den wichtigen Bereich aus.
% Unbestimmte Positionen werden aus dem vorherigen Bild genommen.
% Ein Bereich mit relevanten Daten.
cutXmin = 200;
cutXmax = 370;
cutYmin = 130;
cutYmax = 300;
imgDim = [cutYmax - cutYmin + 1 cutXmax - cutXmin + 1];
dim = size(listXYZ);
x = listXYZ(1, :);
y = listXYZ(2, :);
mask = x >= cutXmin & x <= cutXmax & y >= cutYmin & y <= cutYmax;
mask = repmat(mask, [dim(1) 1]);
listXYZ(~mask) = 0;
listMask = listXYZ(:, any(listXYZ));
elementsNum = (cutXmax - cutXmin) * (cutYmax - cutYmin);
global last_mask;
firstInit = false;
if isempty(last_mask)
last_mask = zeros(dim(1), elementsNum);
firstInit = true;
end;
listRes = last_mask;
x = listMask(1, :);
y = listMask(2, :);
index = 1;
for ix = cutXmin:cutXmax
for iy = cutYmin:cutYmax
i = find(x == ix & y == iy, 1);
if ~isempty(i)
listRes(:, index) = listMask(:, i);
elseif firstInit
listRes(:, index) = [ix; iy; NaN; NaN; NaN];
end
index = index + 1;
end
end
if 0
img = listRes(4, :);
img = reshape(img, imgDim);
imagesc(img);
end
last_mask = listRes;
end