-
Notifications
You must be signed in to change notification settings - Fork 0
/
distanceFilter.m
25 lines (19 loc) · 992 Bytes
/
distanceFilter.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
function svmax = distanceFilter(imgmat, maxmat, dist)
npks = size(maxmat, 1);
% Sieving the found peaks to eliminate duplicates
for s = 1:npks
% Calculate proximity metric vector (each element is the squared
% Cartesian distance between the brightest pixels in the chosen blocks)
proxvec = (maxmat(:,1) - maxmat(s,1)).^2 + (maxmat(:,2) - maxmat(s,2)).^2;
prind = find(proxvec < dist^2,1);
% Proximity elimination: if there are peaks very close by, then compare
% the values of the two peaks and retain the biggest
if prind(1) ~= s && imgmat(maxmat(s,1),maxmat(s,2)) > imgmat(maxmat(prind(1),1),maxmat(prind(1),2))
maxmat(prind(1),:) = [0 0 0];
elseif prind(1) ~= s && imgmat(maxmat(s,1),maxmat(s,2)) <= imgmat(maxmat(prind(1),1),maxmat(prind(1),2))
maxmat(s,:) = [0 0 0];
end
end
% Remove the duplicates found from sieving
svmax = maxmat(maxmat(:,3) ~= 0,:);
end