Académique Documents
Professionnel Documents
Culture Documents
Input x
Output y
System S
1.5 Sampling
1.5.1 Motivation
As we have covered the basic theoretical foundations and start considering several practical issues, it is useful to briefly summarize what we have accomplished so far and to
motivate what lies ahead.
We started by considering some examples of signal processing algorithms in action,
and saw that all those examples fit into one basic picture (Fig. 1.42). We have talked
about a few very basic notions, which the whole field of signal processing is based on,
such as the notions of signals and systems. We concentrated on linear time-invariant
systems and saw that in order to analyze such systems, it was important to study
representations of signals in orthogonal bases:
X
s(n) =
ak gk (n).
k
For example,
when we represented our input signal as the sum of shifted and scaled impulses,
we obtained the interpretation of an LTI system as the convolution of its impulse
response with the input.
when we represented our input signal as the sum of complex exponentials, we got
an equally important interpretation of an LTI systemnamely, that it modifies
different frequency components independently of each other, by multiplying each
component by a complex number. We called these frequency-dependent complex
numbers the frequency response and saw that it was the discrete-time Fourier
transform of the impulse response. We moreover studied the FFT which a fast
algorithm for computing spectral representations of signalsspecifically, the DFT.
Because of these properties of LTI systems, it is very important to be able to think of
signals both in time domain and in frequency domain.
The background material that we covered allows us to begin considering several
important practical matters. One example which will be considered in the lab portion
of this course, is filter design, where the goal may be to attenuate certain frequencies in
a signal and enhance other frequencies. Every time you adjust the bass or treble on your
audio equipment, you are modifying a digital filter. Every time you click enhance in
an image editing program, you are applying a digital filter to the image.
86
Another practical issue that we will start studying shortly is sampling. You may
have noticed that most real-world signals are continuous-time or continuous-space.
When you go to a concert, the music you hear is a continuous-time signal. How can
you reliably store it as discrete samples on a compact disc? Similarly, the world you see
around you is continuous. How can we store digital images on a computer and make
them look realistic and distortion-free? Sampling theory will provide partial answers to
these questions.
X
1 X
n
,
(t nTs ) S(f ) =
f
s(t) =
Ts n=
Ts
n=
i.e., that the CTFT of a periodic impulse train is another periodic impulse train,
as shown in Fig. 1.43.
Convolution with t0 (t) = (t t0 ) is simply a translation by t0 :
Z
( t0 )x(t )d = x(t t0 ).
x t0 (t) =
n
1 X
.
Xc f
=
Ts n=
Ts
(1.36)
87
s(t)
S(f )
1
Ts
CTFT X
X
s s s
s s s
2Ts
Ts 0
Ts
s s s
s s s
T2s
2Ts
T1s 0
2
Ts
1
Ts
s(t)
xc (t)
xs (t)
Convert impulse
train to DT
sequence
x(n) = xc (nTs )
xc (t)
xc (t)
xs (t)
x(n)
s
s
s
2Ts
Ts
Ts
2Ts
s
s
Figure 1.45. An example of xc (t) and the resulting xs (t) and x(n) for Fig. 1.44.
88
To analyze what happens in the frequency domain, we need to relate the DTFT of x(n)
to the CTFTs of xs (t) and xc (t). We do this by using a different method to calculate
the CTFT of xs (t).
xs (t) =
Xs (f ) =
=
=
X
n=
X
n=
X
n=
(t nTs )ej2f t dt
x(n)ej2f Ts n
n=
j
= X(e )|=2f Ts .
Therefore,
= X(ej2f Ts )
X (f )
| s{z }
| {z }
CTFT of xs (t)
DTFT of x(n)
j
.
X(e ) = Xs
2Ts
From this derivation, we see that in order to get X ej from Xs (f ), we just need to
rescale the frequency axis by replacing fs with 2, f2s with etc.
We can now use Eq. (1.36) to express the spectrum of the DT sampled signal in
terms of the spectrum of the original CT signal xc (t):
X(ej ) = Xs
2Ts
=
n
1 X
Xc
.
Ts n=
2Ts Ts
The major point of concern here is how accurately these discrete samples represent the
original CT signal. We will try to answer this question by looking at the spectra and
determining whether the original spectrum Xc (f ) can be recovered by low-pass filtering
X(ej ).
Example 1.28. Sampling and reconstruction.
Consider a signal with the spectrum of Fig. 1.46. Under what circumstances can we
reconstruct this signal from its samples by ideal low-pass filtering?
Case 1. f2s > a.
In this case, the spectrum of the continuous-time sampled signal xs (t) is given in
Fig. 1.47. The original spectrum of Fig. 1.46 can clearly be recovered by filtering
89
Xc (f )
1
A
A
A
A
a 0 a
Xs (f )
fs
A
s s s
A
A
A
fs
A
A
A
A
f2s a 0
A
A
A
A
fs
fs
2
s s s
Figure 1.47. Spectrum of the sampled continuous-time signal xs (t) from Example 1.28 when the
sampling rate is greater than 2a.
H(f )
Ts
xs (t)
xc (t)
f2s
fs
2
Figure 1.48. Reconstruction of xc (t) from xs (t). If the sampling rate is higher than 2a, perfect
reconstruction with an ideal low-pass filter is possible.
Xs (f )
fs
s s s
A
A
A
A A A
fs
fs
s s s
Figure 1.49. Spectrum of the sampled continuous-time signal xs (t) from Example 1.28 when the
sampling rate is less than 2a.
90
aliasing error
frequency truncation error
fs
A
A
f2s 0
fs
2
s(t)
H 0 (f )
xc (t)
x0c (t)
x0s (t)
f2s
fs
2
Xs (f ) with an ideal low-pass filter whose cutoff frequency is fs /2. This is shown
in Fig. 1.48. Thus, perfect reconstruction with an ideal low-pass filter is possible
if the sampling frequency is larger than twice the highest frequency of the signal.
Case 2. f2s a. Referring to Fig. 1.49, we see that it is impossible to recover xc with
a low-pass filter without distortion. The distortion occurs because the spectra of
neighboring copies interfere with the original spectrum. When we filter Xs (f ) with
H(f ), we recover the distorted signal whose spectrum is shown in Fig. 1.50.
One possible way of avoiding this distortion is, as we have seen in Case 1, to
sample at a higher rate. However, if we cannot sample at a higher rate, there is
still something that we can do in order to improve the quality of the reconstruction. Specifically, we can prefilter the continuous-time signal before sampling, to
ensure that the highest frequency of the signal to be sampled is not larger than
fs
0
2 (Fig. 1.51). Let xc (t) be the result of prefiltering xc (t) with the ideal low-pass
0
filter H (f ) depicted in Fig. 1.51. Let x0s (t) be the corresponding continuous-time
sampled signal. If we now try to recover xc (t) from x0s (t) with our ideal low-pass
filter H(f ), we get back x0c (t). Its spectrum, depicted in Fig. 1.52(a), is closer to
the original spectrum than our previous result of Fig. 1.50. The frequencies in the
range [fs a, f2s ] are now recoveredin other words, the aliasing error is removed.
(The frequency truncation error is, however, still present.)
91
Xc0 (f )
Xs0 (f )
fs
A
A
A
f2s 0
s s s
fs
2
A
A
A
A A A
A
A
A
fs
(a)
fs
s s s
(b)
Figure 1.52. Effects of prefiltering, sampling, and reconstruction on the spectrum of the signal of
Example 1.28, Case 2. (a) The spectrum which results from prefiltering with an ideal low-pass filter;
(b) the spectrum of the sampled prefiltered signal. The prefiltered signal can be reconstructed from the
samples by ideal low-pass filtering.
t
Figure 1.53. If sampling rate is lower than the Nyquist rate, some information about the continuoustime signal will be lost in the sampled signal.
92
H 0 (f )
xc (t)
s(t)
x0c (t)
x0s (t)
f2s
Hd (ej )
x(n)
CD
H(f )
yd ()
DC
l
,
l,
fs
2
yc0 (t)
Ts
f2s
yc (t)
fs
2
Figure 1.54. A system for sampling, DT processing, and reconstruction (Example 1.29).
Xc (f )
1/2
1/2
Z
Z
1
1
(f a)ej2f t df +
(f + a)ej2f t df
=
2
2
1 j2at 1 j2at
+ e
=
e
2
2
= cos (2at).
Now we consider the same two cases as in Example 1.28.
93
1. Xc0 (f ) = Xc (f )H 0 (f )
Xc (f )
H 0 (f )
1
2
1
2
1
f2s a 0
2. Xs0 (f ) = Xc0 (f ) S(f )
X
1
0
f
= Xc (f ) Ts
n=
X
1
= Ts
Xc0 f Tns
(recall that
n
Ts
n=
fs = T1s .)
3. X(ej ) = Xs0
1
2Ts
and so
1
2Ts =
2Ts
Hd (ej ) =
2Ts
()
2Ts
= ()
1
2Ts
a
X(ej )
fs
2a
0
fs
2a
fs
X(ej )
Hd (ej )
1
(),
|a|
a 0
fs
2
Xs0 (f )
fs
2Ts
, 0
, 0
2a
fs
2a
fs 0
2a
fs
Yd (ej )
2a
fs
2a
fs 0
2a
fs
2a
fs
94
Yc0 (f )
H(f )
a
Ts
6. Yc (f ) = Yc0 (f )H(f ) =
=
Ts Yc0 (f )
{0
|f |
|f | >
fs
fs
2
fs
2
f2sa 0
fs
2
fs
Yc (f )
aTs
= Ts a{(f a) + (f + a)}
y(t) = 2aTs cos 2at
aTs
Therefore, the overall effect of the system on this particular input signal is equivalent to multiplication by 2aTs .
Case 2. fs < 2a.
In this case, the output will be zero because the whole input signal will be filtered
out by the first low-pass filter H 0 (f ).
Let us now look closer at the reconstruction of an ideally sampled signal. First, we
assume that there is no prefiltering.
Assume that after sampling a continuous-time signal xc (t), we get the samples
xs (t) as in Fig. 1.57(a). What happens when xs (t) goes through the low-pass filter
as in Fig. 1.56? Note that the comb function s(t) and the low-pass filter H(f ) are as
previously defined in Example 1.29, and thus we have:
X
xs (t) =
xc (nTs )(t nTs )
n
s(t)
xc (t)
xs (t)
H(f )
xr (t)
95
1.5
1.5
xr(t)
xs(t)
0.5
0
0.5
0
0.5
5 4 3 2 1 0 1 2 3 4 5
n
0.5
5 4 3 2 1 0 1 2 3 4 5
n
(1.37)
Ts j2f t f = f2s
=
e
f = f2s
j2t
= sinc(fs t).
From Eq. (1.37), it is seen that, in the time domain, reconstruction by low-pass filtering
is equivalent to interpolating the DT signals with sinc functions. The sinc functions are
scaled and added up together to form the reconstructed signal (Fig. 1.57). Again, we
have a representation of the form:
X
ak gk (t),
xr (t) =
k
96
fs
.
2
xr (t)
bandlimited signals
with highest
frequency f2s
Figure 1.58. Prefiltering with an LPF to avoid aliasing is the orthogonal projection of the original
signal on to the space, G of all bandlimited signals with highest frequency f2s .
Why is this interpretation important? The space of all bandlimited signals is good
for approximating smooth signals whose energy is concentrated at low frequencies. It
is well adapted to sound recordings, which are well approximated by lower frequency
harmonics.
For discontinuous signals, such as images, a low-frequency restriction produces the
Gibbs oscillations. If you try to approximate a square pulse (Fig. 1.59(a)) with lowfrequency components, you will get a reconstruction which looks like Fig. 1.59(b).
1
xr(t)
xc(t)
0.5
0.5
97
idea to sample images in the same way sound signals are sampled. For the sampling
and reconstruction of images, it may be better to pick a basis which is different from
the sinc basis, and to project onto a different subspace. However, the basic vector-space
paradigm will remain the same.
This is yet another illustration of the importance of linear algebra in signal processing. It is very important to get used to thinking about signals as vectors. This allows
one to get a broader viewnamely, that much of what we have done in this course is decomposing signals into different bases and working with projections of signals onto the
bases vectors. We have seen that this is the basic idea behind convolution, frequency
analysis and also, sampling.
We next consider several deviations from the ideal sampling model.
xs (t)
q(t)
xc (t)
1
2Ts
Ts
Ts
2Ts
Ts
Ts
Ts
Figure 1.60. The staircase function which results from the sample-and-hold is equal to the ideally
sampled signal convolved with a square pulse.
Therefore,
XZOH (f ) = Xs (f ) CT F T {q(t)}
Z
q(t)ej2f t dt
= Xs (f )
Z
= Xs (f )
Ts
ej2f t dt
#
1 j2f t Ts
e
2j
0
1 1
j2f Ts
= Xs (f )
1e
f 2j
0
1
= Xs (f )
f
"
98
X(f)
1.5
1
0.5
0
2 1.5 1 0.5 0 0.5 1 1.5 2
f
(a) The original spectrum.
2
X (f)
s
T |sinc(fT )|
s
s
1.5
1.5
|XZOH(f)|
Ts|sinc(fTs)|, Xs(f)
1
0.5
1
0.5
0
2 1.5 1 0.5 0 0.5 1 1.5 2
f
0
2 1.5 1 0.5 0 0.5 1 1.5 2
f
(c) |XZOH (f )| for fs = 0.5.
2
Xs(f)
T |sinc(fT )|
s
s
1.5
1
0.5
0
2 1.5 1 0.5 0 0.5 1 1.5 2
f
(d) Sample-and-hold for fs = 1.5.
1.5
|XZOH(f)|
Ts|sinc(fTs)|, Xs(f)
1
0.5
0
2 1.5 1 0.5 0 0.5 1 1.5 2
f
(e) |XZOH (f )| for fs = 1.5.
Figure 1.61. An illustration of the sample-and-hold scheme. (a) The original spectrum. (b) The ideally
sampled spectrum Xs (f ) and the magnitude of the spectrum of the square pulse q(t) for fs = 0.5. (c)
The magnitude of the spectrum of the signal obtained with sample-and-hold, which is the product of
the two spectra in (b). (d,e) The same experiment with sampling rate fs = 1.5.
99
X(ej )
@
@
@
@
@
@
fs
@
@
@
@
@
@
@
@
@
1 jf Ts 1 jf Ts
jf Ts
= Xs (f ) e
e
e
f
2j
sin (f Ts )
= Xs (f )Ts ejf Ts
f Ts
jf Ts
= Xs (f )Ts e
sinc(f Ts )
Hence, |XZOH (f )| = Ts |Xs (f )| |sinc(f Ts )|, i.e., XZOH (f ) is a distorted version of
Xs (f ), as exemplified by Fig. 1.61(b,c). One possible method of reducing the distortion
is to oversample, i.e., to increase the sampling rate beyond the Nyquist rate. As shown
in Fig. 1.61(d,e), this both spreads the aliases farther apart, and makes the center alias
less distorted.
100
x(n)
HLP F (ej )
x (n)
u
xint (n)
xu (3) = x(1)
x(0)
xu (0) = x(0)
x(2)
xu (6) = x(2)
s
0
(a) A DT signal.
x(n)ej(L)n
= X(ejL ).
Step 2. Low-pass filter the interpolated signal.
How is the signal reconstructed? We begin from Fig. 1.65(c),
xint(n) = xu h(n)
(1.38)
where h(n) is the impulse response of the low-pass filteri.e., it is the inverse
DTFT of HLP F of Fig. 1.65(b):
Z
1
HLP F ej ejn d
h(n) =
2
Z
L
1
Lejn d
=
2
L
101
=
L
ejn =L
L
2jn
n
L
sin
=
n
L
n
= sinc
L
=
(1.39)
(1.40)
Now we can get away with a poor analog LPF and still reconstruct the original signal
very well, because the signal spectrum replicas are further apart (Fig. 1.65(c)).
Note that Eq. (1.40) has a form that is similar to the CT reconstruction formula,
Eq. (1.37),
X
t nTs
xr (t) =
.
x(n)sinc
Ts
n
102
x (2) x (3)=x(1)
int
int
xint(1)
1.5
xint(4)
xint(0)=x(0)
xint(5)
xint(n)
x (6)=x(2)
int
0.5
0.5
1
3
n
Figure 1.66. Low-pass filtering the upsampled signal interpolates the reconstructed data points via
sinc functions.
103
(1.41)
xd (1) = x(3)
x(0)
x(2)
x(5)
x(4)
xd (2) = x(6)
x(6)
xd (0) = x(0)
x(1)
(a) A DT signal.
Let us now pretend that x(n) was obtained by sampling a CT signal xc (t). Then
x(n) = xc (nTs ), and, as shown above,
2n
1 X
j
.
X(e ) =
Xc
Ts n
2Ts
Moreover xd (n) = xc (nDTs ), and so we can use the above formula with Ts replaced by
DTs to get:
2n
1 X
j
.
(1.42)
Xd (e ) =
Xc
DTs n
2DTs
To relate Xd (ej ) to X(ej ), we perform a change of variables:
n = k + rD, with < r < , 0 k D 1
Then we have
Xd (ej ) =
=
"
#
D1
( 2k) 2rD
1 X 1 X
Xc
D
Ts r=
2DTs
k=0
"
!#
D1
2k
2r
1 X 1 X
D
Xc
D
Ts r=
2Ts
1
D
k=0
D1
X
k=0
2k
.
X ej D
(1.43)
104
The spectrum of the downsampled signal is therefore the sum of shifted replicas of the
stretched spectrum of the original DT signal, as illustrated in Fig. 1.68.
Xc (f )
B
B
B
r r r
fs
B
B
B
a
X(ej )
B
B
B
B
B
B
2 2aTs 2aTs
r r r
fs
D
r r r
Xd (ej )
r r r
2 2aDTs 2aDTs 2
j
1
D
DX e
r r r
J
2D
r r r
fs
D
fs
D
r r r
2 2aDTs 2aDTs 2
2
1
ej D
DX
2D
r r r
2D + 2
2D
2D + 2
Figure 1.68. Comparison between signal spectra. In this pictorial example, D = 2. Refer to the
derivation of Eq. (1.43).
x (n)
x(n)
xd (n)