3D Gaussian Filter in MATLAB

Bill Cheatham picture Bill Cheatham · Jun 13, 2011 · Viewed 15.2k times · Source

Is there a 3D eqivalent of imfilter available for MATLAB? I wish to apply Gaussian filtering to a 3D histogram. I was going to implement it myself, by creating a (3D) Gaussian filter, then looping over each element in my histogram, and summing up the corresponding data entries.

However, I didn't want to implement it myself in a slow and inefficient way if there's something already out there, or a cleverer way of doing it.

Answer

Jonas picture Jonas · Jun 13, 2011

There are two ways to solve this in order to do the filtering in an efficient manner:

(1) Use CONVN three times to filter your data with three 1D Gaussians, one x-by-1-by-1, one 1-by-y-by-1, and one 1-by-1-by-z.

(2) If you have the signal processing toolbox, use FFTFILT to perform filtering in inverse space (or use any one of the fft-convolution algorithms on the file exchange).

[(3) Send me an email and I'll send you my fftFilterImage, which does 3D Gauss filtering.]