-
Notifications
You must be signed in to change notification settings - Fork 0
/
nonLocalMaximaSuppression.m
67 lines (59 loc) · 2.38 KB
/
nonLocalMaximaSuppression.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
63
64
65
66
67
function [ nlms ] = nonLocalMaximaSuppression( rotationResponse, theta , suppressionValue)
%nonLocalMaximaSuppression Suppress pixels which are not local maxima in
%both orientation and filter response
%
% INPUT
% rotationResponse: matrix Y by X by R, R = # of rotation angles
% (4th output of steerableDetector or steerableVanGinkelFilter)
% theta: (optional) rotation angles. Default: (0:R-1)*pi/R
% suppressionValue: (optional) value to give suppressed pixels (def: 0)
%
% OUTPUT
% nlms: rotationResponse with non-local maxima set to suppressedValue
%
% Copyright (C) 2019, Jaqaman Lab - UT Southwestern, Goldman Lab - Northwestern
%
% This file is part of AdaptiveResolutionOrientationSpace.
%
% AdaptiveResolutionOrientationSpace 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.
%
% AdaptiveResolutionOrientationSpace 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 AdaptiveResolutionOrientationSpace. If not, see <http://www.gnu.org/licenses/>.
%
%
% Mark Kittisopikul, 2015
% UT Southwestern
% TODO: full-backwards compatability with nonMaximumSuppression?
nO = size(rotationResponse,3);
if(nargin < 2 || isempty(theta))
% default value is the rotation planes correspond to angles that
% equally divide pi
theta = 0:nO-1;
theta = theta*pi/nO;
%TODO: allow for theta of different sizes
end
if(nargin < 3)
suppressionValue = 0;
end
% if(nargin < 4)
% distance = 1;
% end
nlms = rotationResponse;
% TODO: optimize later
for o = 1:nO
nlms(:,:,o) = nonMaximumSuppression(rotationResponse(:,:,o),theta(o));
end
% suppression response if less than the previous or next orientation
% response
% nlms(nlms < nlms(:,:,[2:end 1]) | nlms < nlms(:,:,[end 1:end-1])) = suppressionValue;
nlms(rotationResponse < rotationResponse(:,:,[2:end 1]) | rotationResponse < rotationResponse(:,:,[end 1:end-1])) = suppressionValue;
% what if equal on either side or both sides?
end % end of function