Image Processing Toolbox User's Guide |
Design two-dimensional FIR filter using frequency sampling
Syntax
Description
fsamp2
designs two-dimensional FIR filters based on a desired two-dimensional frequency response sampled at points on the Cartesian plane.
h = fsamp2(Hd
) designs a two-dimensional FIR filter with frequency response Hd
, and returns the filter coefficients in matrix h
. (fsamp2
returns h
as a computational molecule, which is the appropriate form to use with filter2
.) The filter h
has a frequency response that passes through points in Hd
. If Hd
is m
-by-n
, then h
is also m
-by-n
.
Hd
is a matrix containing the desired frequency response sampled at equally spaced points between -1.0 and 1.0 along the x and y frequency axes, where 1.0 corresponds to half the sampling frequency, or radians.
For accurate results, use frequency points returned by freqspace
to create Hd
. (See the entry for freqspace
for more information.)
h = fsamp2(f1,f2,Hd,[m n])
produces an m
-by-n
FIR filter by matching the filter response at the points in the vectors f1
and f2
. The frequency vectors f1
and f2
are in normalized frequency, where 1.0 corresponds to half the sampling frequency, or radians. The resulting filter fits the desired response as closely as possible in the least squares sense. For best results, there must be at least m*n
desired frequency points. fsamp2
issues a warning if you specify fewer than m*n
points.
Class Support
The input matrix Hd
can be of class double
or of any integer class. All other inputs to fsamp2
must be of class double
. All outputs are of class double
.
Example
Use fsamp2
to design an approximately symmetric two-dimensional bandpass filter with passband between 0.1 and 0.5 (normalized frequency, where 1.0 corresponds to half the sampling frequency, or radians):
Hd
that contains the desired bandpass response. Use freqspace
to create the frequency range vectors f1
and f2
.
[f1,f2] = freqspace(21,'meshgrid');
Hd = ones(21);
r = sqrt(f1.^2 + f2.^2);
Hd((r<0.1)|
(r>0.5))= 0;
colormap(jet(64)) mesh(f1,f2,Hd)
Algorithm
fsamp2
computes the filter h
by taking the inverse discrete Fourier transform of the desired frequency response. If the desired frequency response is real and symmetric (zero phase), the resulting filter is also zero phase.
See Also
conv2
, filter2
, freqspace
, ftrans2
, fwind1
, fwind2
Reference
[1] Lim, Jae S., Two-Dimensional Signal and Image Processing, Englewood Cliffs, NJ, Prentice Hall, 1990, pp. 213-217.
freqz2 | fspecial |
© 1994-2005 The MathWorks, Inc.