wolffd@0
|
1 % NONMAXSUP - Non-maximal Suppression
|
wolffd@0
|
2 %
|
wolffd@0
|
3 % Usage: cim = nonmaxsup(im, radius)
|
wolffd@0
|
4 %
|
wolffd@0
|
5 % Arguments:
|
wolffd@0
|
6 % im - image to be processed.
|
wolffd@0
|
7 % radius - radius of region considered in non-maximal
|
wolffd@0
|
8 % suppression (optional). Typical values to use might
|
wolffd@0
|
9 % be 1-3. Default is 1.
|
wolffd@0
|
10 %
|
wolffd@0
|
11 % Returns:
|
wolffd@0
|
12 % cim - image with pixels that are not maximal within a
|
wolffd@0
|
13 % square neighborhood zeroed out.
|
wolffd@0
|
14
|
wolffd@0
|
15 % Copyright (C) 2002 Mark A. Paskin
|
wolffd@0
|
16 %
|
wolffd@0
|
17 % This program is free software; you can redistribute it and/or modify
|
wolffd@0
|
18 % it under the terms of the GNU General Public License as published by
|
wolffd@0
|
19 % the Free Software Foundation; either version 2 of the License, or
|
wolffd@0
|
20 % (at your option) any later version.
|
wolffd@0
|
21 %
|
wolffd@0
|
22 % This program is distributed in the hope that it will be useful, but
|
wolffd@0
|
23 % WITHOUT ANY WARRANTY; without even the implied warranty of
|
wolffd@0
|
24 % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
wolffd@0
|
25 % General Public License for more details.
|
wolffd@0
|
26 %
|
wolffd@0
|
27 % You should have received a copy of the GNU General Public License
|
wolffd@0
|
28 % along with this program; if not, write to the Free Software
|
wolffd@0
|
29 % Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
|
wolffd@0
|
30 % USA.
|
wolffd@0
|
31 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
wolffd@0
|
32
|
wolffd@0
|
33 function cim = nonmaxsup(m, radius)
|
wolffd@0
|
34 if (nargin == 1) radius = 1; end
|
wolffd@0
|
35 % Extract local maxima by performing a grey scale morphological
|
wolffd@0
|
36 % dilation and then finding points in the corner strength image that
|
wolffd@0
|
37 % match the dilated image and are also greater than the threshold.
|
wolffd@0
|
38 sze = 2 * radius + 1; % Size of mask.
|
wolffd@0
|
39 mx = ordfilt2(m, sze^2, ones(sze)); % Grey-scale dilate.
|
wolffd@0
|
40 cim = sparse(m .* (m == mx));
|
wolffd@0
|
41
|
wolffd@0
|
42
|