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