-
Notifications
You must be signed in to change notification settings - Fork 5
/
find_local_max.m
48 lines (40 loc) · 1.23 KB
/
find_local_max.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
function [LoMaVal, LoMaLoc, LoMaInd] = find_local_max(J, curryloc, r)
LoMaInd = [];
m = length(J);
continue_flag = ones(1, m);
for i = 1 : m
if( continue_flag(i) )
dist = norms(curryloc - repmat(curryloc(:, i), [1, m]));
adjVec = (dist <= r);
blean = nnz((J(i) - J(adjVec)) < 0);
if( ~blean )
LoMaInd = [LoMaInd i];
continue_flag(adjVec) = 0;
end
end
end
LoMaVal = J(LoMaInd);
LoMaLoc = curryloc(:, LoMaInd);
end
% for i = 1 : m
% dist = norms(curryloc - repmat(curryloc(:, i), [1, m]));
% adjVec = (dist <= r) & (dist > 0);
% blean = nnz((J(i) - J(adjVec)) <= 0);
% blean_curry = ismember(curryloc(:, i).', curryloc(:, LoMaInd).', 'rows');
% if( ~blean && ~blean_curry )
% LoMaInd = [LoMaInd i];
% end
% end
% continue_flag = ones(1, m);
% [~, ind_srt] = sort(J, 'descend');
% for i = 1 : m
% if( continue_flag(i) )
% dist = norms(curryloc - repmat(curryloc(:, ind_srt(i)), [1, m]));
% adjVec = (dist <= r);
% blean = nnz((J(ind_srt(i)) - J(adjVec)) < 0);
% if( ~blean )
% LoMaInd = [LoMaInd ind_srt(i)];
% continue_flag((dist(ind_srt) <= r)) = 0;
% end
% end
% end