Design Linear Filters in the Frequency Domain
这个帮助文档写得很好,简单明了,一句废话没有。
This topic describes functions that perform filtering in the frequency domain.
2-D Finite Impulse Response (FIR) Filters
The Image Processing Toolbox™ software supports one class of linear filter: the two-dimensional finite impulse response (FIR) filter. FIR filters have a finite extent to a single point, or impulse. All of the Image Processing Toolbox filter design functions return FIR filters.
FIR filters have several characteristics that make them ideal for image processing in the MATLAB® environment:
-
FIR filters are easy to represent as matrices of coefficients.
-
Two-dimensional FIR filters are natural extensions of one-dimensional FIR filters.
-
There are several well-known, reliable methods for FIR filter design.
-
FIR filters are easy to implement.
-
FIR filters can be designed to have linear phase, which helps prevent distortion.
Another class of filter, the infinite impulse response (IIR) filter, is not as suitable for image processing applications. It lacks the inherent stability and ease of design and implementation of the FIR filter. Therefore, this toolbox does not provide IIR filter support.
FIR 滤波器的主要缺点是,要达到同样的性能水平,其所需阶数远高于 IIR 滤波器。相应地,这些滤波器的延迟通常比同等性能的 IIR 滤波器大得多。
其实冈萨雷斯想的也是FIR滤波器,因为IIR滤波器就不能通过卷积实现。只是他的概念太不清楚了,就把模拟、IIR、FIR各种滤波器混在了一起。
Create Filter Using Frequency Sampling Method
This example shows how to create a 2-D filter based on a desired frequency response using the frequency sampling method.
Given a matrix of points that define the shape of the frequency response, the frequency sampling method creates a filter whose frequency response passes through those points. Frequency sampling places no constraints on the behavior of the frequency response between the given points. Usually, the response ripples in these areas. Ripples are oscillations around a constant value. The frequency response of a practical filter often has ripples where the frequency response of an ideal filter is flat.
Create the filter based on the target frequency response using the fsamp2 function. fsamp2
returns the filter h with a frequency response that passes through the points in the input matrix Hd.
Notice the ripples in the actual frequency response compared to the desired frequency response. These ripples are a fundamental problem with the frequency sampling design method. They occur wherever there are sharp transitions in the desired response.
You can reduce the spatial extent of the ripples by using a larger filter. However, a larger filter does not reduce the height of the ripples, and requires more computation time for filtering. To achieve a smoother approximation to the desired frequency response, consider using the frequency transformation method or the windowing method.
Create Filter Using Windowing Method
The windowing method involves multiplying the ideal impulse response with a window function to generate a corresponding filter, which tapers the ideal impulse response. Like the frequency sampling method, the windowing method produces a filter whose frequency response approximates a desired frequency response. The windowing method, however, tends to produce better results than the frequency sampling method.
The toolbox provides two functions that design two-dimensionsal filters using a window-based filter design.
fwind1
converts one or two one-dimensional windows that you specify into a two-dimensional window.
fwind2
uses a two-dimensional window that you specify.
fwind1
supports two different methods for making the two-dimensional windows:
When you specify a single one-dimensional window, fwind1
transforms the one-dimensional window using a process similar to rotation. The two-dimensional window is nearly circularly symmetric.
When you specify two one-dimensional windows, fwind1
computes their outer product. The two-dimensional window is rectangular and separable.
Create 2-D Filter Using Frequency Transformation of 1-D Filter
This example shows how to transform a one-dimensional FIR filter into a two-dimensional FIR filter using the ftrans2
function. This function can be useful because it is easier to design a one-dimensional filter with particular characteristics than a corresponding two-dimensional filter. The frequency transformation method preserves most of the characteristics of the one-dimensional filter, particularly the transition bandwidth and ripple characteristics. The shape of the one-dimensional frequency response is clearly evident in the two-dimensional response.
This function uses a transformation matrix, a set of elements that defines the frequency transformation. This function’s default transformation matrix produces filters with nearly circular symmetry. By defining your own transformation matrix, you can obtain different symmetries. (See Jae S. Lim, Two-Dimensional Signal and Image Processing, 1990, for details.)