-
Notifications
You must be signed in to change notification settings - Fork 168
/
Copy pathbb_points.m
53 lines (44 loc) · 1.41 KB
/
bb_points.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
% Copyright 2011 Zdenek Kalal
%
% This file is part of TLD.
%
% TLD is free software: you can redistribute it and/or modify
% it under the terms of the GNU General Public License as published by
% the Free Software Foundation, either version 3 of the License, or
% (at your option) any later version.
%
% TLD is distributed in the hope that it will be useful,
% but WITHOUT ANY WARRANTY; without even the implied warranty of
% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
% GNU General Public License for more details.
%
% You should have received a copy of the GNU General Public License
% along with TLD. If not, see <http://www.gnu.org/licenses/>.
function pt = bb_points(bb,numM,numN,margin)
% Generates numM x numN points on BBox.
bb(1:2) = bb(1:2)+margin;
bb(3:4) = bb(3:4)-margin;
if (numM == 1 && numN ==1)
pt = bb_center(bb);
return;
end
if (numM == 1 && numN > 1)
c = bb_center(bb);
stepW = (bb(3)-bb(1)) / (numN - 1);
pt = ntuples(bb(1):stepW:bb(3),c(2));
return;
end
if (numM > 1 && numN == 1)
c = bb_center(bb);
stepH = (bb(4)-bb(2)) / (numM - 1);
pt = ntuples(c(1),(bb(2):stepH:bb(4)));
return;
end
stepW = (bb(3)-bb(1)) / (numN - 1);
stepH = (bb(4)-bb(2)) / (numM - 1);
pt = ntuples(bb(1):stepW:bb(3),(bb(2):stepH:bb(4)));
if size(pt,2) < numM*numN
count = numM * numN - size(pt, 2);
app = repmat(pt(:,end), 1, count);
pt = [pt, app];
end