Daniel@0: % NONMAXSUP - Non-maximal Suppression Daniel@0: % Daniel@0: % Usage: cim = nonmaxsup(im, radius) Daniel@0: % Daniel@0: % Arguments: Daniel@0: % im - image to be processed. Daniel@0: % radius - radius of region considered in non-maximal Daniel@0: % suppression (optional). Typical values to use might Daniel@0: % be 1-3. Default is 1. Daniel@0: % Daniel@0: % Returns: Daniel@0: % cim - image with pixels that are not maximal within a Daniel@0: % square neighborhood zeroed out. Daniel@0: Daniel@0: % Copyright (C) 2002 Mark A. Paskin Daniel@0: % Daniel@0: % This program is free software; you can redistribute it and/or modify Daniel@0: % it under the terms of the GNU General Public License as published by Daniel@0: % the Free Software Foundation; either version 2 of the License, or Daniel@0: % (at your option) any later version. Daniel@0: % Daniel@0: % This program is distributed in the hope that it will be useful, but Daniel@0: % WITHOUT ANY WARRANTY; without even the implied warranty of Daniel@0: % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Daniel@0: % General Public License for more details. Daniel@0: % Daniel@0: % You should have received a copy of the GNU General Public License Daniel@0: % along with this program; if not, write to the Free Software Daniel@0: % Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 Daniel@0: % USA. Daniel@0: %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% Daniel@0: Daniel@0: function cim = nonmaxsup(m, radius) Daniel@0: if (nargin == 1) radius = 1; end Daniel@0: % Extract local maxima by performing a grey scale morphological Daniel@0: % dilation and then finding points in the corner strength image that Daniel@0: % match the dilated image and are also greater than the threshold. Daniel@0: sze = 2 * radius + 1; % Size of mask. Daniel@0: mx = ordfilt2(m, sze^2, ones(sze)); % Grey-scale dilate. Daniel@0: cim = sparse(m .* (m == mx)); Daniel@0: Daniel@0: