2-D FIR filter using 2-D window method
fwind2 function designs 2-D FIR filters using the
fwind2 uses a 2-D window specification to design a
2-D FIR filter based on the desired frequency response.
with 2-D windows only. Use
fwind1 to create a 2-D FIR filter from a
You can apply the 2-D FIR filter to images by using the
Create 2-D FIR Filter using 2-D Window Method
This example shows how to design an approximately circularly symmetric two-dimensional bandpass filter using a 2-D window method.
Create the frequency range vectors
freqspace. These vectors have length 21.
[f1,f2] = freqspace(21,'meshgrid');
Compute the distance of each position from the center frequency.
r = sqrt(f1.^2 + f2.^2);
Create a matrix
Hd that contains the desired bandpass response. In this example, the desired passband is between 0.1 and 0.5 (normalized frequency, where 1.0 corresponds to half the sampling frequency, or radians).
Hd = ones(21); Hd((r<0.1)|(r>0.5)) = 0;
Display the ideal bandpass response.
Create a 2-D Gaussian window using
fspecial. Normalize the window.
win = fspecial('gaussian',21,2); win = win ./ max(win(:));
Display the window.
Using the 2-D window, design the filter that best produces the desired frequency response
h = fwind2(Hd,win);
Display the actual frequency response of this filter.
Hd — Desired frequency response
Desired frequency response at equally spaced points in the Cartesian
plane, specified as a numeric matrix. For accurate results, create
Hd by using the
win — 2-D window
2-D window, specified as a numeric matrix.
f1 — Desired frequency along the x-axis
Desired frequency along the x-axis. The frequency vector should be in the range [-1, 1], where 1.0 corresponds to half the sampling frequency, or π radians.
f2 — Desired frequency along the y-axis
Desired frequency along the y-axis. The frequency vector should be in the range [-1, 1], where 1.0 corresponds to half the sampling frequency, or π radians.
h — 2-D FIR filter
2-D FIR filter, returned as a numeric matrix of the same size as
h using an inverse Fourier
transform and multiplication by the two-dimensional window
 Lim, Jae S., Two-Dimensional Signal and Image Processing, Englewood Cliffs, NJ, Prentice Hall, 1990, pp. 202-213.
Introduced before R2006a