# Applying Lowpass (LPF) and Highpass (HPF) Filters to an Image in Frequency Domain in MATLAB

What I want is simply to apply low pass and highpass filters to an image in the frequency domain. Does MATLAB image processing toolbox have any commands for this?

• Did you take a look into imfilter? – Tolga Birdal Dec 31 '14 at 13:53
• conv2 can also be helpful – Andrey Rubshtein Jan 4 '15 at 12:40
• Is it a requirement that you use the image processing toolbox? You can always just zeropad --> fft --> multiply --> ifft. – AnonSubmitter85 Dec 9 '15 at 18:37

You can use spatial Methods using Convolution (conv2 and imfilter).
You can do it in Frequency Domain using the Convolution Theorem property using fft.

Usually, In Image Processing, all filters are built using Gaussian Kernel.
High Pass is basically subtracting Low Pass filtered image from the original image.

You can create the Gaussian Kernel manually or using fspecial.

For fast implementation, have a look here - Fast Gaussian Blur.

P.S.
For people who use conv, be aware that conv is using conv2 and you can reduce the overhead by using it directly.

I spatial domain, simply convolve masks like averaging, or guassian with image to get low pass filtering: