EE 4078: Zero-Padding the FFT (1995–) 1 Finite Signal Length 2

advertisement
EE 4078: Zero-Padding the FFT (1995–)
1
Finite Signal Length
The DFT demands that the signal length be finite, e.g., the N-point DFT operates on an N-element data
vector x[n] to produce an N-element result in the frequency domain X[k].
X[k] =
N−1
X
x[n]e− j2πnk/N
(1)
n=0
If the actual signal length is L which is less than N, the data vector can be artifically extends by
“zero-padding” which amounts to adding zeros at the end. Suppose that the original signal v[n] is only
non-zero over the range 0 ≤ n < L. Then x[n] for the DFT is
½
v[n] for n = 0, 1, 2, . . . L−1
(2)
x[n] =
0
for n = L, L+1, . . . N −1
For example, if v[n] has length L = 100, and we wish to compute a length-512 FFT, then 412 zeros
must be appended when forming x[n].
2
Frequency Sampling Property
The DFT (Discrete Fourier Transform) can be obtained directly from the DTFT (Discrete-Time Fourier
Transform) by merely doing a sampling operation:
¯
X[k] = V (e jω )¯ω = 2πk/N
(3)
because the DTFT formula is
V (e ) =
jω
L−1
X
v[n]e− jnω
(4)
n=0
and the DFT formula above (1) can be written as
X[k] =
L−1
X
v[n]e− j2πnk/N
(5)
n=0
when the definition of x[n] in (2) is taken into account.
The sampling defined by (3) can be interpreted as interpolation when N is increased. If the FFT
length N is doubled, then twice as many frequency samples are produced. For example, consider the
case where L = 32 and the FFT lengths are N = 64 and N = 128. The frequency sampling grids are
½
¾
½
¾
2π
2π
k, k = 0, 1, 2, . . . , 63
and
k, k = 0, 1, 2, . . . , 127
64
128
The grid for the 128-point case includes the grid for the 64-point case when k is even, and the new
values for 2πk/128 when k is odd make up an interpolation of the values on the 64-point grid.
EE-4078: INTERPOLATION via ZERO-PADDING
Recall that interpolation can be done with the FFT by using zero-padding in the time domain. In a
previous example, we use a signal x[n] which consists of 32 points of a cosine wave:
x[n] = sin(2π(7/32)n + π/6)
n = 0, 1, 2, . . . 31
ZERO-PADDED VERSION of x[n]
1
0
-1
0
10
20
30
40
TIME INDEX (n)
50
60
If we compute the DFT of x[n] by using the FFT algorithm with different amounts of zero padding
at the end, then we can compare the frequency domain plots and notice how the longer FFT lengths
gives more samples of X(e jω ) in the frequency domain.
DFT of 32-point x[n]
DFT of 64-point ZERO-PADDED x[n]
15
15
10
10
5
5
0
0
0
0
5
10
15
20
DFT INDEX (k)
25
30
15
15
10
10
5
5
20
40
60
80
DFT INDEX (k)
100
120
20
30
40
DFT INDEX (k)
50
60
DTFT approx with 1024-point DFT
128-point DFT of ZERO-PADDED x[n]
0
0
10
0
0
1
2
3
4
5
FREQUENCY (ω) [0,2π]
6
In this case, the underlying DTFT is two Dirichlet functions, one centered at ω = 7π/16, and the other
centered at ω = −7π/16. The 1024-pt FFT has such a dense frequency sampling that it appears to give
the true DTFT shape.
BAND-LIMITED INTERPOLATION of TIME-DOMAIN SIGNALS
We can also do this for interpolation in the time domain. In that case, we call the procedure Bandlimited
Interpolation because it corresponds to the use of an ideal low-pass filter. Of course, we cannot actually
realize an ideal lowpass filter, which has a “sinc” function time response, but we can approximate it.
The procedure involves the following steps:
1. Take the N-point FFT of the data.
2. Zero-pad in the middle of the frequency domain data, X[k]. For example, if you are adding 3N
zeros, then make up the new frequency domain vector by taking the first N/2 + 1 points from
X[k], then the 3N zeros, and finally the last N/2 − 1 points from X[n]. This is illustrated in
the figure that shows the 64-point FFT and a 256-pt FFT frequency domain vector that has been
“padded in the middle.”
3. Now take the IFFT of the zero-padded vector. The length of this IFFT will be an integer multiple
of N, e.g., if we are interpolating up by a factor of 4, then we will use a length 4N IFFT.
The zero padding must be done “in the middle,” because we are actually doing lowpass filtering
and must preserve the negative frequency components of the signal which are at the indices near NFFT .
In addition, when the signal is real-valued, we must preserve the conjugate symmetry in the transform
domain. Recal that when x[n] is real, its DFT X[k] satisfies:
C ONJUGATE -S YMMETRY:
X[−k mod N] = X ∗ [k]
The FFT’s below are for the following example: is a speech waveform that has been interpolated
“up” by a factor of four. The detail is shown for the shaded region which consists of samples 25 through
34 in the original “raw” data. First, we show an example of zero-padding in the middle:
64-pt DFT of RAW (MAGNITUDE)
10
5
0
0
10
20
30
40
50
60
256-pt DFT with MIDDLE ZERO PADDING
10
5
0
0
50
100
150
200
250
FREQUENCY INDEX (k)
RAW DATA at 4000 Hz
(64 POINTS)
1
0
-1
0
5
10
INTERPOLATED DATA at 16000 Hz (256 POINTS)
15
1
0
-1
0
5
10
15
TIME (millisec)
INTERPOLATED (4X)
RAW DATA
1
1
0.5
0.5
0
0
-0.5
-0.5
-1
-1
26
28
30
INDEX (n)
32
34
100
105
110
115
120
INDEX (n)
125
130
135
Download