In MATLAB R2015a or newer, it is no longer necessary (or advisable from a performance standpoint) to use fspecial
followed by imfilter
since there is a new function called imgaussfilt
that performs this operation in one step and more efficiently.
The basic syntax:
B = imgaussfilt(A,sigma)
filters imageA
with a 2-D Gaussian smoothing kernel with standard deviation specified bysigma
.
The size of the filter for a given Gaussian standard deviation (sigam
) is chosen automatically, but can also be specified manually:
B = imgaussfilt(A,sigma,'FilterSize',[3 3]);
The default is 2*ceil(2*sigma)+1
.
Additional features of imgaussfilter
are ability to operate on gpuArray
s, filtering in frequency or spacial domain, and advanced image padding options. It looks a lot like IPP... hmmm. Plus, there's a 3D version called imgaussfilt3
.