Sei sulla pagina 1di 15

EECE603Fadi N Karameh 1

AMERICAN UNIVERSITY OF BEIRUT


Department of Electrical and Computer Engineering
EECE603S - Biomedical Signal and Image Processing.
Lecture Notes 4
Prof. Fadi N Karameh
1 The Discrete Fourier Transform
The discussion we have presented so far deals with the Fourier representation of
discrete time signals using the Discrete Time Fourier Transform (DTFT) which is a
continuous periodic function. The DTFT, therefore, is not a practical tool since its
computation is very expensive. To approximate the DTFT, we will utilize a spectral
sampling technique known as the Discrete Fourier Transform DFT. We will show
that the obtained spectral samples can indeed fully represent nite length sequences
x[n]. In the next section, we will motivate the DFT by considering the DTFT of a
periodic signal. We will then discuss condition for perfect spectral representation.
The properties and utility of a DFT will then be presented.
1.1 The DTFT of a periodic signal
Consider a periodic DT signal x
p
[n] with a period N. Its DTFT is given by
X
p
(e
j
) =

n=
x
p
[n]e
jn
(1)
A simple way of deriving this summation is to consider the signal over a single period
N, that is, let
x[n] = x
p
[n]R
N
[n] =
_
x
p
[n], 0 n N 1;
0, else.
(2)
The periodic signal can then be represented as an innite sum of kN-shifted ver-
sions of x[n]:
x
p
[n] =

k=
x[n kN] = x[n]

k=
[n kN] (3)
Taking the DTFT now, we obtain
X
p
(e
j
) = X(e
j
).
2
N

k=
(
2
N
k) =
2
N

k=
X(e
j
2
N
k
)(
2
N
k) (4)
where
X(e
j
) =

n=
x[n]e
jn
=
N1

n=0
x[n]e
jn
EECE603Fadi N Karameh 2
Therefore, X
p
(e
j
) is a sampled version of the length N signal SpectrumX(e
j
)|
=
2
N
k
at frequency intervals of
2
N
k, < k < . Therefore, the DTFT of a periodic signal
is also periodic, and more importantly discrete.
1.2 The DFT:
Based on the above treatment, one can see that given a nite-length signal x[n] of
length N with a continuous DTFT X(e
j
), a devised N-periodic version of that signal
x
p
[n] =

l=
x[n lN] has a discrete DTFT consisting of N samples of X(e
j
).
Accordingly, one can dene these N samples to be the Discrete Fourier Transform of
x[n].
Analysis equation: x[n]
NDFT


X[k] =
N1

n=0
x[n]e
j
2k
N
n
0 k N 1 (5)
Where

X[k] = X(e
j
2k
N
) = X(e
j
)|
=
2
N
k
(6)
The DFT analysis equation dene a set of coecients

X[k] 0 k N 1 which
can be utilized to estimate the continuous spectrum of any discrete signal x[n] by
taking only N samples of it. It is obvious, therefore, that some conditions must be
imposed (on x[n]) such that the sampling procedure in equation 5 does not cause loss
of information, or allows reconstructing x[n] from the samples X[k].
1.2.1 Reconstruction of x[n] from its DFT
Consider a a DT signal x[n] of length L which admits some DTFT X(e
j
). Our
objective is to sample its continuous spectrum X(e
j
) at regular frequency intervals
of, say
2
N
, for some N of our choice. The sampling procedure can be represented by
multiplication, in frequency, by a picket fence function:
X
s
(e
j
) = X(e
j
).

k=
(
2
N
k) (7)
which in time domain corresponds to
x
s
[n] = x[n]
N
2

l=
(n lN) =
N
2

l=
x[n lN] (8)
A graphical interpretation of this procedure is shown in gure 1. It is obvious
that x[n] can be reconstructed from x
s
[n] if L 1 < N or N L. In this case,
x
[
n] =

l=
x[n lN].R
N
[n] =
_
2
N
x
s
[n], 0 n N 1;
0, else.
(9)
EECE603Fadi N Karameh 3
Figure 1: Sampling DTFT at using N-pt DFT
If, however, N < L, then x
s
[n] will be a time-aliased version of x[n], which means
that the sample rate in frequency
N
2
was not fast enough, or that the samples were
too wide apart. Finally, and since an N-point DFT

X[k] is actually doing sampling in
the frequency domain at intervals of
2
N
, then x[n] can be synthesized or reconstructed
exactly from

X[k] if N L.
Example 1 (from Proakis)
Given a signal x[n] = a
n
u[n] |a| < 1. Find the reconstructed signal x
1
[n] and its
corresponding spectrum X
1
(e
j
) if the spectrum of x[n] is sampled at
2
N
.
Solution: To start, the DTFT of x[n] is given by
X(e
j
) =

n=
x[n]e
jn
=

n=o
a
n
e
jn
=

n=o
(ae
j
)
n
=
1
1 ae
j
Sampling X(e
j
) at
2
N
samples/radian, we obtain
X
s
(e
j
) =
1
1 ae
j
2
N
k
with the corresponding time signal given by
x
s
[n] =
N
2

l=
x[n lN] =
N
2

l=
a
nlN
u[n lN]
from which we obtain the single period signal x
1
[n] as in equation 9.
x
1
[n] =

l=
x[n lN]R
N
[n] (0 n N 1)
EECE603Fadi N Karameh 4
Figure 2: Example 1
X
1
[n] =
0

l=
a
nlN
= a
n

l=0
a
lN
==
a
n
1 a
N
0 n N 1
from the above it is obvious that x
1
[n] = x[n] with the approximation getting closer
as N grows larger (gure 2).
Now we can also evaluate how close the reconstructed DTFT X
1
(e
j
) is from the
original DTFT we sampled.
1(e
j
) =

n=
x
1
[n]e
jn
=
N1

n=0
a
n
1 a
N
e
jn
which leads to
X
1
(e
j
) =
1
1 a
N
N1

n=0
(ae
j
)
n
=
1
1 a
N
1 a
N
e
jN
1 ae
j
One can see that X
1
(e
j
) = X(e
j
) except at sample points
2
N
k. In between
samples, the two DTFTs are dierent for any nite number of samples, mainly since
the sampled signal in this case has an innite time support.
Example 2 Spectral sampling can also be utilized to design FIR lters. In partic-
ular, assume that one proposes a desired lter response H
d
(e
j
), then a
2
N
-sampled
spectrum H
s
(e
j
) will create, in time an FIR sequence given by equation 9.
h
FIR
=

l=
h
d
[n lN]R
N
[n]
It can be seen that the goodness of the approximation depends in fact on the length
of the actual lter h[n]. In general, the length of h[n] depends on the sharpness of
EECE603Fadi N Karameh 5
the desired lter characteristics H
d
(e
j
): If very sharp cuto is desired, then h[n] is
an innite sequence and h
FIR
[n] is a time-aliased version of it regardless of N. As we
saw in the previous example, the lter of the FIR lter H
FIR
(e
j
) will match H
d
(e
j
)
only at the sample points. In between, the approximation will fail where ripples will
be created, known as Gibbs Phenomenon (to be discussed later).
1.3 The inverse DFT
As we presented above, it is possible to reconstruct any nite length DT signal x[n]
(length L) from spectral samples at
2
N
if N L. Alternatively, a signal x[n] can be
constructed from is N-point DFT if N L. One way to derive the synthesis formula
is as follows. From Equation 7, one can use the DTFT formula to obtain x
s
[n]
x
s
[n] =
1
2
_

X
s
(e
j
)e
jn
d =
1
2
_
2
0
X(e
j
)

l=
(
2
N
l)e
jn
d (10)
x
s
[n] =
1
2

l=
_
2
0
X(e
j
)(
2
N
l)e
jn
d =
1
2
N1

l=0
X(e
j
2
N
l
)e
j
2
N
ln
(11)
where the last summation occurs since [0, 2] translates into a summation in
l [0, N 1]. Finally, the sifting property of the (Omega
2
N
l) was utilized.
If N L, then the reconstructed signal x[n] is related to x
s
[n] by equation 9,
giving
x[n] =
1
N
N1

k=0
X(e
j
2
N
k
)e
j
2
N
kn
(12)
Synthesis equation:

X[k]
NIDFT
x[n] =
1
N
N1

k=0

X[k]e
j
2
N
kn
0 n N 1
(13)
and we repeat here the analysis equation
Analysis equation: x[n]
NDFT


X[k] =
N1

n=0
x[n]e
j
2k
N
n
0 k N 1 (14)
Equations 14and 13 represent a relationship between two sequences of N numbers x[n]
and

X[k]. It can also be thought of as a change of basis from [nk], k = 0 . . . N 1
into exponential basis along the circle e
j
2k
N
n
, k = 0 . . . N 1.
EECE603Fadi N Karameh 6
Relationship to DTFS, periodic signals The Discrete transform is tightly cou-
pled to the Discrete Time Fourier Series. Considering a periodic signal x
p
[n] of period
N, then it can be represented as
x
p
[n] =
N1

k=0

C
x,k
e
j
2k
N
n
(15)
where

C
x,k
=
1
N
N1

n=0
x
p
[n]e
j
2n
N
k
(16)
On comparing the above with the N point DFT of a nite length sequence
x[n] = x
p
[n]R
N
[n]
given exactly by equation 14, we notice that

X[k] = N

C
x,k
(17)
which means that the two expansions have essentially the same properties. While one
deals with periodic signals of length N explicitly (DTFS), the other (DFT) implicitly
expands into periodic versions all nite length signals of length L N. It is obvious
then that the Discrete Fourier transform of any periodic signal

X
p
[k] is the same as
the DFT of one period of it

X[k].

X
p
[k] =

X[k] (18)
1.4 Properties of the DFT
We will next present basic properties of DFT that are of relevance to our projects.
Throughout, consider a DT signal x[n] of nite length L with an associated N-point
DFT

X[k], N L.
1. Periodicity:

X[k] =

X[k + N] for any k, x[n] = x[n + N] for any n (19)
The last equation follows from the synthesis equation, although, strictly speak-
ing, x[n] does not exist outside 0, N 1, but rather its periodized version x
p
[n]
does.
2. Linearity:
ax[n] + by[n]
NDFT
a

X[k] + b

Y [k] (20)
3. Circular shift by n
o
:
To understand the shifting of nite length x[n], we will consider its periodized
version
x
p
[n] =

l=
x[n lN]
EECE603Fadi N Karameh 7
Figure 3: Example of circular shift
with the understanding that both have the same DFT (as seen in equation 18).
Accordingly, a shifted x
p
[n] will have the same DFT as a shifted nite length
sequence x[n].
Let x
p1
[n] = x
p
[n n
o
] =

l=
x[n lN n
o
], then it is easy to see that,
since x
1
[n] = x
p1
[n]R
N
[n] that the n
o
shift will correspond to a circular shift in
x[n]. That is,
x
1
[n] = x
p1
[n]R
N
[n] = x[n n
o
, modulo N]

= x[(n n
o
)
N
] (21)
Therefore, we will use the fact that the circular shift of x[n] corresponds to a
linear shift in x
p
[n] to nd the corresponding DFT. Mainly,
x[n]
NDFT


X[k] (22)
x[(n n
o
)
N
] = x
p
[n n
o
]R
N
[n]
NDFT
e
j
2k
N
no
X[k] (23)
proof:

X
p1
[k] =
N1

n=o
x
p
[n n
o
]e
j
2n
N
k
(24)
=
no+N1

n=no
x
p
[n]e
j
2(n+no)
N
k
(25)
EECE603Fadi N Karameh 8
Figure 4: A sequence reversed in time
where n = n + n
o
was used, then:

X
p1
[k] = e
j
2(no)
N
k
N1

n=0
x
p
[n]e
j
2n
N
k
(26)
= e
j
2k
N
no
X
p
[k] (27)
4. Time reversal: We will again use the periodic signal x
p
[n] to determine the DFT.
First note that,
x
p
[n] = x
p
[N n]
, therefore
x[(n)
N
] = x
p
[N n]R
N
[n].
An example of a time reversal is shown in gure 4.
Now, the DFT of the shift x
p
[n] is
x
p
[n] = x
p
[N n]
NDFT


X[N k] =

X

[k]
real signals
=

X[k]
Therefore if x[n] is real, then
x[(n)
N
]
NDFT

[k] =

X

[k] =

X[k] (28)
5. Even, Odd signals:
x
e
[n] =
x[n] + x[N n]
2
NDFT

X[k] +

X[N k
2
=

X
Re
[k] (29)
x
o
[n] =
x[n] x[N n]
2
NDFT

X[k]

X[N k
2
= j

X
Im
[k] (30)
EECE603Fadi N Karameh 9
Figure 5: Convolution
6. Multiplication of DFTs: Given two sequences x[n], y[n] of length L
1
, L
2
, re-
spectively, then the multiplication of their N-point DFT ( Ngeq max(L
1
, L
2
) is
closely related to their convolution.

Z[k] =

X[k]

Y [k]
NIDFT
z[n] = x[n]
N
y[n]

=
N1

m=0
x[m]y[(n m)
N
] (31)
where
N
is cyclic convolution of the involved sequences. This property is fairly
important in ltering computations as we will see later.
7. Multiplication of DT sequences: The dual of the above property is given as
z[n] = x[n]y[n]
NDFT


Z[k] =
1
N
_

X[k]
N

Y [k]
_

=
1
N
N1

m=0

X[m]

Y [(k m)
N
]
(32)
Example: convolution We will now study the similarities between linear con-
volution y[n] = x
1
[n] x
2
[n] and circular convolution y[n] = x
1
[n]
N
x
2
[n]. We will
see that the two are in fact equivalent if care is taken in choosing N, the period of
circular convolution.
Let x
1
[n] = x
2
[n] = [n] +[n1] +[n2]. If we compute the linear convolution
y
l
[n] = x
1
[n] x
2
[n], then it is easy to see that y
l
[0] = y
l
[4] = 1, y
l
[1] = y
l
[3] = 2 and
y
l
[2] = 3.
To compute y[n] = x
1
[n]
N
x
2
[n], let us rst choose N=3 (equal to the size of x
1
[n]
and x
2
[n]). Then, as seen in gure 5, y[0] = y[1] = y[2] = 3 (given a = b = c = 1)
EECE603Fadi N Karameh 10
Figure 6: Convolution with N=5
which is not the same as the linear convolution result y
l
[n]. Note that the circular
convolution could have been preformed as multiplication in the frequency domain
using DFTs. That is, if
x
1
[n]
NDFT
X
1
[k] x
2
[n]
NDFT


X
2
[k],
then

Y [k] =

X
1
[k]

X
2
[k]. Here,

X
1
[k] =

X
2
[k] =
2

n=0
(1)e
j
2k
3
n
=
_
3, k=0;
0, else.
(the above is always true if we sum complex exponentials over the unit circle :
N1

n=0
e
j
2k
N
n
=
_
N, k=0;
0, else.
)
Therefore

Y [k] =
_
9, k=0;
0, else.
and
y[n] =
1
3
2

k=0

Y [k]e
j
2k
3
n
=
1
3

Y [0] = 3 0 n 3
which agrees with the circular convolution result.
Now if we choose N= length of DFT= length(x
1
[n])+length(x
2
[n]) 1 = 5, then
gure 6 shows that y[n] = y
l
[n] and hence linear and circular convolution in fact are
interchangable in this case.
EECE603Fadi N Karameh 11
Figure 7: Convolution with N=4
Note that the above example worked since, looking at the computation of y[0],
x[(0 m)
5
] has only the rst sample x[0] included while the rest of the sequence is
warped to the end of the interval to the right (starting at N=5 and backwards to 4).
For x[(nm)
N
] n > 0, these samples are introduced at the beginning of the sequence
to the left, just as we expect in a linear convolution.
If, on the other hand, we choose N = 4, then we see (gure 7) that in computing
y[0], we have included the contribution of x[0] as well as of one of the samples that
are warped to the end of the interval to the right (at n=3). Therefore, y[0] is not
what we expect from a linear convolution, i.e. it is aliased.
In general given two sequences x[n] of length L
1
and y[n] of length L
2
, then linear
and N-circular convolution coincide if:
x[n] y[n] = x[n]
N
y[n] if N L
1
+ L
2
1 (33)
This is very advantageous since then we can then use DFT to compute the linear
convolutions. DFTs in their turn are very easy to compute with fast algorithms like
FFTs for huge overall saving in computations compared to linear convolutions.
1.5 Linear ltering using DFTs
As we have seen above, the ability to express a linear convolution as a circular con-
volution (under some conditions) allows the utilization of DFTs in performing the
computations. This is especially attractive in ltering problems. Assume that an
FIR lter h[n] of length M is used to process a very long sequence of data x[n] of
length L
T
. The data could be recorded at a fast sampling rate, and as such can be
very sizable for any period of time collected (44.1 KHz audio signal will give 44,100
samples for each second of data to be processed). Performing the computation
y[n] = h[n] x[n]
requires drastic memory storage and is computationally expensive. To utilize DFTs
in the computation necessitates computing the N
T
point DFT where N
T
= L
T
+M+1
EECE603Fadi N Karameh 12
Figure 8: Convolution with a long data causes M-1 corrupted initial points
which is still quite prohibitive. In addition, the data might be coming in sequentially
which eectively makes L
T
ever growing, and prohibits an on-line DFT computation
(as data comes in). To solve this problem, we will decompose the data into smaller
blocks and compute outputs for each of these blocks. The output is in general not the
same as for the one-block data, but as we will see, some of the data will be corrupted
while other output data will be correct, which we could store.
1.5.1 Overlap-save method
The idea behind this is to decompose the input into blocks. Consider for example
data block x
1
[n] of length L (x[n], 0 n L 1, and L << L
T
). Let the FIR lter
h[n] be of length M (h[n], 0 n M 1, M << L). Then, if we extend both
sequences to N = L + M 1 and perform the circular convolution
y
1
[n] = x
1
[n]
N
h[n],
the result is not the correct linear convolution, but it is close. To see this, gure 8
shows which specic data points will be corrupted. Starting with h[(m)
N
] we see
that the last M 1 points of h[n] are actually wrapped around to the tail end after
L-1 (occupying L, L+1, . . . N). If x[n] was in fact only of length L, then y[n] = y
1
[n]
0 n N 1, however since x
1
[n] is only a block of x[n], the wrapped data will
give an aliased result y
1
[n]. Aliasing will persist until all the lter taps are wrapped
back into the beginning or until y
1
[M 1]. Accordingly y
1
[M], y
1
[M + 1], . . . y
1
[N]
will be the correct convolution result, or
y[n] = y
1
[n] M n N
Since the rst M 1 points are corrupted, the overlap-save method is based on
storing these from the previous overlapped block, as we will see next.
In what follows, dene x
m
[n] as a data block of length N, its corresponding output
will then be
y
m
[n] = x
m
[n]
N
h[n]
EECE603Fadi N Karameh 13
which can be computed by DFT: rst compute

H[k] once and store it, then compute

X
m
[k] to nd y
m
[n] = IDFT(

X
m
[k]

H[k]). Then,
y
m
[n] =
_
y
m
[0], y
m
[1], . . . y
m
[M 2]
. .
, y
m
[M 1], . . . y
m
[N 1]
. .
_
M-1 corrupted points good points
and therefore, the actual output gained from x
m
[n] is
y
m
[n] = y
m
[n] n = M 1, M, . . . , N 1
The overlap-save method is thus formulated as follows (see gure 9):
1. Form an initial block x
1
[n] as
x
1
[n] =
_
0, 0, . . . 0
. .
, x[0], x[1] . . . x[L 1]
. .
_
M-1 zeros L data points
2. Compute y
1
[n]. Store y[n] = y
1
[n + M], 0 n L 1. (i.e. store only last L
points).
3. For the next block x
2
[n] as
x
2
[n] =
_
x[L M + 1], . . . , x[L 1]
. .
, x[L], x[L + 1] . . . x[2L 1]
. .
_
M-1 points from x
1
[n] L new data points
4. Compute y
2
[n]. Store y[n+L] = y
2
[n+M], 0 n L1. (i.e. store only last
L points).
5. Repeat. Each time overlapping x
k
[n] with x
k1
[n] by M-1 points which are
to be discarded from the computation, as their eect have been stored in the
previous block.
1.6 Spectral sampling using DFTs
As we have discussed in the time-frequency resolution lecture, the ability to resolve
dierent frequencies depends on the width of the time window. Consider for example
the signal
x[n] = cos 0.15n + cos 0.17n + cos 0.4n
EECE603Fadi N Karameh 14
Figure 9: Block schematic of Overlap Save method
If we collect a record of L points of this signal, we are eectively multiplying x[n] by
a rectangular window R
L
[n] (0 n L 1) Therefore
x
1
[n] = x[n]R
L
[n] (34)
which , after taking DTFT becomes
X
1
(e
j
) =
1
2
X(e
j
)
L
R
L
(e
j
) (35)
where
R
L
(e
j
) = e
j(L1)/2
sin(L/2)
sin(/2)
(36)
X(e
j
) = [( 0.15) + ( + 0.15) + ( 0.17)]
+ [( + 0.17) + ( 0.4) + ( + 0.4)]
Therefore, X
1
(e
j
) will be shifted versions of R
L
(e
j
). The latter has a main lobe
width of 4/L. Therefore, any two frequencies w
o
, w
1
can only be resolved if |w
o

w
1
| 2/L.
In gure 10, we took three lengths of the window, L = 40, 70 and 100. Note that
at N = 40, the two frequencies 0.15 and 0.17 are completely merged since the main
lobe of R
40
(e
j
) is very wide. Note also the side lobes which erroneously tell that
the signal has a wide spectrum; this phenomenon is called spectral leakage. Note
here that we have computed the above gure using a DFT where N = 2048. The
length N is only to get a ner resolution estimate of X
1
(e
j
) but it cannot improve
our knowledge of it since this is based solely on L.
As N is increased, better resolution is obtained, and the side lobes (spectral leak-
age) is decreased. Finally, for L = 100 =
2
|0.150.17|
, the two close frequencies can
be deciphered.
In truncating the data to length N, one can apply dierent forms of windows which
could have smaller side lobes, and thus reduce spectral leakage (Hamming, Hanning,
Blackmann). These, however, will have wider main lobes, and thus frequency resolu-
tion will decrease.
EECE603Fadi N Karameh 15
Figure 10: Eect of window length on frequency resolution

Potrebbero piacerti anche