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