File Exchange

image thumbnail


version (4.28 KB) by Dirk-Jan Kroon
Fast Gaussian filtering of 1D, 2D greyscale / color image or 3D image volume.


Updated 01 Oct 2009

View License

IMGAUSSIAN filters an 1D, 2D color/greyscale or 3D image with a Gaussian filter.

Instead of using a multidimensional Gaussian kernel, it uses the fact that a Gaussian kernel can be separated in 1D kernels.

By the default the code uses IMFILTER for the filtering. But also a cache efficient MEX / c-code implementation is included. Compile with: "mex imgaussian.c -v"


Comparison time needed to filter image volume of 512x512x512 with Gaussian kernel of sigma 1:
- 90.8 seconds : Imfilter with 3D gaussian kernel
- 21.8 seconds : Imgaussian using imfilter
- 8.18 seconds : Imgaussian using the MEX file

For small 2D images ( < 1024x1024 ) or large kernels (sigma 10), Imgaussian using imfilter is faster than the MEX file. This is because imfilter uses the "Intel Performance Primitives Library", and the MEX file only normal cache optimized c-code.

Comments and Ratings (6)

Royi Avital

Could you compare it to:

I think the IIR method would be even much faster.



Linux Ubuntu Tested

MATLAB Release Compatibility
Created with R2009b
Compatible with any release
Platform Compatibility
Windows macOS Linux