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?
You can use spatial Methods using Convolution (
You can do it in Frequency Domain using the Convolution Theorem property using
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
For fast implementation, have a look here - Fast Gaussian Blur.
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:
LowpassMask=(1/9)*ones(3,3); % Averaging mask of size 3*3 Filtered=conv2(image,LowpassMask);
for high pass filtering, either convolve it with a differntiator mask like sobel or subtract already low passed image from the original image:
Sobel=[-1 0 1]; Filtered=conv2(image,Sobel);
However, since you mentioned frequency domain filtering, I explain it a little bit also. In frequency domain you can take 2D FFT of the image and then mask part of it based on low-pass or high-pass filter you desire, to get the 2D FFT of the image use, fft2, then mask central parts for low pass filtering or corners for high-passing filtering.