% GAUSSFILT - Small wrapper function for convenient Gaussian filtering % % Usage: smim = gaussfilt(im, sigma) % % Arguments: im - Image to be smoothed. % sigma - Standard deviation of Gaussian filter. % % Returns: smim - Smoothed image. % % See also: INTEGGAUSSFILT % Peter Kovesi % Centre for Explortion Targeting % The University of Western Australia % http://www.csse.uwa.edu.au/~pk/research/matlabfns/ % March 2010 function smim = gaussfilt(im, sigma) assert(ndims(im) == 2, 'Image must be greyscale'); % If needed convert im to double if ~strcmp(class(im),'double') im = double(im); end sze = ceil(6*sigma); if ~mod(sze,2) % Ensure filter size is odd sze = sze+1; end sze = max(sze,1); % and make sure it is at least 1 h = fspecial('gaussian', [sze sze], sigma); smim = filter2(h, im);