Documentation

fwind2

2-D FIR filter using 2-D window method

Description

example

h = fwind2(Hd,win) produces the two-dimensional FIR filter h using an inverse Fourier transform of the desired frequency response Hd and multiplication by the window win. Hd is a matrix containing the desired frequency response at equally spaced points in the Cartesian plane. fwind2 returns h as a computational molecule, which is the appropriate form to use with filter2. h is the same size as win.

Use fwind2 to design two-dimensional FIR filters using the window method. fwind2 uses a two-dimensional window specification to design a two-dimensional FIR filter based on the desired frequency response Hd. fwind2 works with two-dimensional windows; use fwind1 to work with one-dimensional windows.

For accurate results, use frequency points returned by freqspace to create Hd.

h = fwind2(f1,f2,Hd,win) lets you specify the desired frequency response Hd at arbitrary frequencies (f1 and f2) along the x- and y-axes. The frequency vectors f1 and f2 should be in the range -1.0 to 1.0, where 1.0 corresponds to half the sampling frequency, or π radians. h is the same size as win.

Examples

collapse all

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 f1 and f2 using 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 $\pi$ radians).

Hd = ones(21);
Hd((r<0.1)|(r>0.5)) = 0;

Display the ideal bandpass response.

colormap(parula(64))
mesh(f1,f2,Hd) Create a 2-D Gaussian window using fspecial. Normalize the window.

win = fspecial('gaussian',21,2);
win = win ./ max(win(:));

Display the window.

mesh(win) 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.

freqz2(h) Input Arguments

collapse all

Desired frequency response, at equally spaced points in the Cartesian plane, specified as a numeric matrix. The input matrix Hd can be of class double or of any integer class. All other inputs to fwind2 must be of class double. All outputs are of class double.

Data Types: single | double | int8 | int16 | int32 | int64 | uint8 | uint16 | uint32 | uint64

2-D window, specified as a numeric matrix.

Data Types: single | double

Desired frequency along the x-axis. The frequency vector should be in the range -1.0 to 1.0, where 1.0 corresponds to half the sampling frequency, or π radians.

Data Types: single | double

Desired frequency along the y-axis. The frequency vector should be in the range -1.0 to 1.0, where 1.0 corresponds to half the sampling frequency, or π radians.

Data Types: single | double

Output Arguments

collapse all

2-D FIR filter, returned as a numeric matrix.

Algorithms

fwind2 computes h using an inverse Fourier transform and multiplication by the two-dimensional window win.

${h}_{d}\left({n}_{1},{n}_{2}\right)=\frac{1}{{\left(2\pi \right)}^{2}}{\int }_{-\pi }^{\pi }{\int }_{-\pi }^{\pi }{H}_{d}\left({\omega }_{1},{\omega }_{2}\right){e}^{j{\omega }_{1}{n}_{1}}{e}^{j{\omega }_{2}{n}_{2}}d{\omega }_{1}d{\omega }_{2}$

$h\left({n}_{1},{n}_{2}\right)={h}_{d}\left({n}_{1},{n}_{2}\right)w\left({n}_{1},{n}_{2}\right)$

 Lim, Jae S., Two-Dimensional Signal and Image Processing, Englewood Cliffs, NJ, Prentice Hall, 1990, pp. 202-213.