lec dft fft
DESCRIPTION
discrete time Fourier transformTRANSCRIPT
Dr. Shoab Khan
Digital Signal Processing
Lecture
Discrete-Time Fourier Series
The conventional (continuous-time) FS represent a periodic signal using an infinite number of complex exponentials, whereas the DFS represent such a signal using a finite number of complex exponentials
Example 2 DFS of an periodic rectangular pulse train
The DFS coefficients
10/ksin
2/ksine
e1
e1ekX
~ 10/k4j
k10/2j
5k10/2j4
0n
kn10/2j
Properties of DFS Linearity
Shift of a Sequence
Duality
kX~
bkX~
anx~bnx~a
kX~
nx~kX
~nx~
21DFS
21
2DFS
2
1DFS
1
mkX~
nx~e
kX~
emnx~kX
~nx~
DFSN/nm2j
N/km2jDFS
DFS
kx~NnX
~kX
~nx~
DFS
DFS
Periodic Convolution Take two periodic sequences
Let’s form the product
The periodic sequence with given DFS can be written as
Periodic convolution is commutative
kX
~nx~
kX~
nx~
2DFS
2
1DFS
1
kX~
kX~
kX~
213
1N
0m213 mnx~mx~nx~
1N
0m123 mnx~mx~nx~
Graphical Periodic Convolution
DTFT to DFT
Sampling the Fourier Transform Consider an aperiodic sequence with a Fourier transform
Assume that a sequence is obtained by sampling the DTFT
Since the DTFT is periodic resulting sequence is also periodic
We can also write it in terms of the z-transform
The sampling points are shown in figure
could be the DFS of a sequence
Write the corresponding sequence
kN/2j
kN/2
j eXeXkX~
jDTFT eX]n[x
kN/2j
ezeXzXkX
~kN/2
kX~
1N
0k
knN/2jekX~
N
1]n[x~
DFT Analysis and Synthesis
DFT is Periodic with period N
Properties of DFT Linearity
Duality
Circular Shift of a Sequence
kbXkaXnbxnax
kXnx
kXnx
21DFT
21
2DFT
2
1DFT
1
mN/k2jDFT
N
DFT
ekX1-Nn0 mnx
kXnx
N
DFT
DFT
kNxnX
kXnx
DFT Properties
Example: Circular Shift
Example: Circular Shift
Example: Circular Shift
Duality
Circular Flip
Properties: Circular Convolution
Example: Circular Convolution
Example: Circular Convolution
illustration of the circular convolution process
Example (continued)
Illustration of circular convolution for N = 8:
03/17/2011 CS267 Lecture 18
Using the 2D FFT for image compression
° Image = 200x320 matrix of values
° Compress by keeping largest 2.5% of FFT components
° Similar idea used by jpeg
void dft(complex_float* in, complex_float* out, int N, int inv)
{
int i, j;
float a, f;
complex_float s, w;
f = inv ? 1.0/N : 1.0;
for (i = 0; i < N; i++) {
s.re = 0;
s.im = 0;
for (j = 0; j < N; j++) {
a = -2*PI*i*j/N;
if (inv) a = -a;
w.re = cos(a);
w.im = sin(a);
s.re += in[j].re * w.re - in[j].im * w.im;
s.im += in[j].im * w.re + in[j].re * w.im;
}
out[i].re = s.re*f;
out[i].im = s.im*f;
}
DFT & IDFT
DFT Properties
Circular Convolution
Filtering of Long Data Sequences
The input signal x(n) is often very long especially in real-time signal processing applications.
For linear filtering via the DFT, for example, the signal must be limited size due to memory requirements
Filtering of Long Data Sequences
Segment the input signal into fixed-size blocks prior to processing.
Compute DFT-based linear filtering of each block separately via the FFT.
Fit the output blocks together in such a way that the overall output is equivalent to the linear filtering of x(n) directly.
Main advantage: samples of the output y(n) = h(n) ⊗ x(n) will be available real-time on a block-by-block basis.
Filtering of Long Data Sequences
Goal: FIR filtering: y(n) = x(n) * h(n)
Two approaches to real-time linear filtering of long inputs:
Overlap-Add Method
Overlap-Save Method
Assumptions:
FIR filter h(n) length = P
Block length = L ≫ P
For example, consider two sequences h[n] and x[n] as follows.
Segmenting x[n]
into L-length
sequences. Each
segment is padded
by P1 zero values.
Fir filtering by
using the
overlapping-add
method.
Overlap-Add Method
1. Break the input signal x(n) into non-overlapping blocks xm(n) of length L.
2. Zero pad h(n) to be of length N = L + M -1
3. Take N-DFT of h(n) to give H(k), k = 0; 1, …,N-1
4. For each block m:
1. Zero pad xm(n) to be of length N = L + M-1
2. Take N-DFT of xm(n) to give Xm(k), k = 0,1,…,N-1
3. Multiply: Ym(k) = Xm(k)H(k), k = 0,1,…,N -1
4. Take N-IDFT of Ym(k) to give ym(n), n = 0,1,…,N-1
5. Form y(n) by overlapping the last M-1 samples of ym(n) with the first M -1 samples of ym+1(n) and adding the result
Example of overlapping-save method
Decompose x[n] into overlapping sections
of length L
Example of overlapping-save method (continue)
Result of circularly convolving each section with h[n]. The portions
of each filter section to be discarded in forming the linear convolution
are indicated
Overlap-Save Method
Overlap-Save Method
Using DFT for Circular Convolution
N = L + M -1
Let xm(n) have support n = 01,2,…,N -1
Let h(n) have support n = 01,2,…,M-1
We zero pad h(n) to have support n = 01,2,…,N-1
1. Take N-DFT of xm(n) to give Xm(k), k = 0,1,2,….,N-1
2. Take N-DFT of h(n) to give H(k), k = 0,1,2,….,N-1
3. Multiply: Ym(k) = Xm(k) H(k), k = 0,1,2,….,N-1
4. Take N-IDFT of Ym(k) to give yC,m(n), n = 01,2,…,N-1