Filter Image in Frequency Domain
This example shows how to apply Gaussian lowpass filter to an image using the 2-D FFT block.
Example Model
Open the Simulink® model.
modelname = "ex_blk2dfft.slx";
open_system(modelname)
Read Input Image
The model reads an input image using the Image From File block and converts the image data type to double
using the Image Data Type Conversion block.
Create 2-D Filtering Mask
The model uses the Constant (Simulink) block to create a predefined 2-D filter mask for rotationally symmetric Gaussian lowpass filter using the fspecial
function.
Apply Gaussian Lowpass Filter
The model uses 2-D FFT blocks to compute two-dimensional fast Fourier transforms of the input image and filtering mask. The FFT Shift
blocks are MATLAB Function (Simulink) blocks that shift the zero-frequency component to the center of the spectrum. To apply the filter, the model multiplies the spectra of the input image and filtering mask using the Product block. Then, the model computes 2-D inverse Fast Fourier Transform (IFFT) of the resulting product using the 2-D IFFT block and finds its absolute value using the Abs (Simulink) block. Finally, the model uses IFFT Shift
block to undo the effect of FFT shift operation and rearrange the output image.
Simulate and Display Results
Simulate the model. The Video Viewer blocks display the input and output images. Notice that output image is blurred version of the input image because the application of 2-D Gaussian lowpass filter averages out rapid changes (high-frequency contents) in intensity.
sim(modelname);