Documentation

fwind1

2-D FIR filter using 1-D window method

Description

example

h = fwind1(Hd,win) uses a 1-D window specification to design a two-dimensional FIR filter h based on the desired frequency response Hd. fwind1 returns h as a computational molecule, which is the appropriate form to use with filter2. fwind1 uses the one-dimensional window win to form an approximately circularly symmetric two-dimensional window using Huang's method.

fwind1 works with 1-D windows only; use fwind2 to work with two-dimensional windows.

h = fwind1(Hd,win1,win2) uses the two 1-D windows, win1 and win2, to create a separable 2-D window. If length(win1) is n and length(win2) is m, then h is m-by-n. The length of the windows controls the size of the resulting filter.

h = fwind1(f1,f2,Hd,___) lets you specify the desired frequency response Hd at arbitrary frequencies (f1 and f2) along the x- and y-axes.

Examples

collapse all

This example shows how to design an approximately circularly symmetric two-dimensional bandpass filter using a 1-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) Design the 1-D window. This example uses a Hamming window of length 21.

win = 0.54 - 0.46*cos(2*pi*(0:20)/20);

Plot the 1-D window.

figure
plot(linspace(-1,1,21),win); Using the 1-D window, design the filter that best produces this frequency response

h = fwind1(Hd,win);

Display the actual frequency response of this filter.

freqz2(h) Input Arguments

collapse all

Desired frequency response, specified as a numeric matrix. Hd is sampled at equally spaced points between -1.0 and 1.0 (in normalized frequency, where 1.0 corresponds to half the sampling frequency, or π radians) along the x and y frequency axes. For accurate results, use frequency points returned by freqspace to create Hd.

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

1-D window, specified as a numeric matrix. You can specify win using windows from the Signal Processing Toolbox software, such as boxcar, hamming, hanning, bartlett, blackman, kaiser, or chebwin. If length(win) is n, then h is n-by-n.The length of the window controls the size of the resulting filter.

Data Types: single | double

1-D window, specified as a numeric matrix.

Data Types: single | double

1-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 of class double, when the input Hd is of class double or any integer class. If Hd is of class single, the output matrix is of class single.

Algorithms

fwind1 takes a one-dimensional window specification and forms an approximately circularly symmetric two-dimensional window using Huang's method,

$w\left({n}_{1},{n}_{2}\right)={w\left(t\right)|}_{t=\sqrt{{n}_{{}_{1}}^{2}+{n}_{2}^{2}}},$

where w(t) is the one-dimensional window and w(n1,n2) is the resulting two-dimensional window.

Given two windows, fwind1 forms a separable two-dimensional window:

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

fwind1 calls fwind2 with Hd and the two-dimensional window. fwind2 computes h using an inverse Fourier transform and multiplication by the two-dimensional window:

${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}_{2},{n}_{2}\right).$

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