Upload
others
View
17
Download
0
Embed Size (px)
Citation preview
6.003: Signal Processing
Sampling and Reconstruction
September 13, 2018
Importance of Discrete Representations
Our goal is to develop signal processing tools that help us under-
stand and manipulate the world.
Model Result
World New Understanding
make model
analyze
(math, computation)
interpret results
System Behavior
analysis
design
The increasing power and decreasing cost of computation makes the
use of computation increasingly attractive. However, many impor-
tant signals are naturally described with continuous domain.
→ understand the relation between CT and sampled signals
Sampling
Converting continuous-time (CT) signals to discrete time (DT).
t
x(t)
0T 2T 4T 6T 8T 10Tn
x[n] = x(nT )
0 2 4 6 8 10
T = sampling interval
How does sampling affect the information contained in a signal?
Sampling
We would like to sample in a way that preserves information.
However, information is clearly lost in the sampling process.
t
x(t)
From this example, it’s clear that uniformly spaced samples tell us
nothing about the values of x(t) between the samples.
Sampling
Even worse, information can be distorted, becoming misinformation.
Samples of an original signal x(t) = cos 7π3 n
t
cos 7π3 n? cos π3n?
are just as easily interpreted as coming from cos π3n.
Effects of Undersampling Are Easily Heard
Sampling Music
fs = 1T
• fs = 44.1 kHz
• fs = 22 kHz
• fs = 11 kHz
• fs = 5.5 kHz
• fs = 2.8 kHz
J.S. Bach, Sonata No. 1 in G minor Mvmt. IV. Presto
Nathan Milstein, violin
Effects of Undersampling are Easily Seen
Sampling Images
original: 2048× 1536
Effects of Undersampling are Easily Seen
Sampling Images
downsampled: 1024× 768
Effects of Undersampling are Easily Seen
Sampling Images
downsampled: 512x384
Effects of Undersampling are Easily Seen
Sampling Images
downsampled: 256× 192
Effects of Undersampling are Easily Seen
Sampling Images
downsampled: 128× 96
Effects of Undersampling are Easily Seen
Sampling Images
downsampled: 64× 48
Effects of Undersampling are Easily Seen
Sampling Images
downsampled: 32× 24
Effects of Undersampling
If we hope to use sampled signals to understand behaviors of con-
tinuous signals, we must understand effects of sampling.
Effects of Undersampling
If we hope to use sampled signals to understand behaviors of con-
tinuous signals, we must understand effects of sampling.
Some of the effects of undersampling arise from fundamental prop-
erties of discrete time.
CT: x(t) = cosωt
DT: x[n] = cos Ωn
These signals differ in important ways.
Check Yourself
Compare two signals:
x1[n] = cos 3πn4
x2[n] = cos 5πn4
How many of the following statements are true?
x1[n] has period N=8.
x2[n] has period N=8.
x1[n] = x2[n].
Check Yourself
t
cos 3πt4 = cosω1t
t
cos 5πt4 = cosω2t
ω1 6= ω2
but x1[n] = x2[n]!
ω1 + ω2 = 2πcosω1n = cos(2π − ω2)n = cos(2πn− ω2n) = cos(−ω2n) = cosω2n
Check Yourself
Compare two signals:
x1[n] = cos 3πn4
x2[n] = cos 5πn4
How many of the following statements are true? 3
x1[n] has period N=8.√
x2[n] has period N=8.√
x1[n] = x2[n].√
Check Yourself
Consider 3 CT signals:
x1(t) = cos(4000t) ; x2(t) = cos(5000t) ; x3(t) = cos(6000t)
Each of these is sampled so that
x1[n] = x1(nT ) ; x2[n] = x2(nT ) ; x3[n] = x3(nT )
where T = 0.001.
Which list goes from lowest to highest DT frequency?
0. x1[n] x2[n] x3[n] 1. x1[n] x3[n] x2[n]
2. x2[n] x1[n] x3[n] 3. x2[n] x3[n] x1[n]
4. x3[n] x1[n] x2[n] 5. x3[n] x2[n] x1[n]
Check Yourself
The CT signals are simple sinusoids:
x1(t) = cos(4000t) ; x2(t) = cos(5000t) ; x3(t) = cos(6000t)
The DT signals are sampled versions (T = 0.001):
x1[n] = cos(4n) ; x2[n] = cos(5n) ; x3[n] = cos(6n)
How does the shape of cos(Ωn) depend on Ω?
Check Yourself
As the frequency Ω increases, the shapes of the sampled signals
deviate from those of the underlying CT signals.
n
Ω = 1 : x[n] = cos(n)
n
Ω = 2 : x[n] = cos(2n)
n
Ω = 3 : x[n] = cos(3n)
Check Yourself
Worse and worse representation.ΩL
n
Ω = 4 : x[n] = cos(4n) = cos(2π − 4n) ≈ cos(2.283n)
n
Ω = 5 : x[n] = cos(5n) = cos(2π − 5n) ≈ cos(1.283n)
n
Ω = 6 : x[n] = cos(6n) = cos(2π − 6n) ≈ cos(0.283n)
The same DT sequence represents many different values of Ω.
Check Yourself
For Ω > π, a lower frequency ΩL has the same sample values as Ω.
n
Ω = 4 : x[n] = cos(4n) = cos(2π − 4n) ≈ cos(2.283n)
n
n
Ω = 5 : x[n] = cos(5n) = cos(2π − 5n) ≈ cos(1.283n)
n
n
Ω = 6 : x[n] = cos(6n) = cos(2π − 6n) ≈ cos(0.283n)
n
The same DT sequence represents many different values of Ω.
Check Yourself
Although there are multiple frequencies Ω with the same samples,
only one of these frequencies is in the range 0 ≤ Ω ≤ π.
Thus we can remove the ambiguity of which frequency is represented
by a set of samples by choosing the one in the range 0 ≤ Ω ≤ π.
We call that range of frequencies the base band of frequencies.
If we limit our attention to frequencies in the base band, then there
is a maximum possible discrete frequency Ωmax = π.
Note this difference from CT, where there is no maximum frequency.
Check Yourself
Consider 3 CT signals:
x1(t) = cos(4000t) ; x2(t) = cos(5000t) ; x3(t) = cos(6000t)
Each of these is sampled so that
x1[n] = x1(nT ) ; x2[n] = x2(nT ) ; x3[n] = x3(nT )
where T = 0.001.
Which list goes from lowest to highest DT frequency? 5
0. x1[n] x2[n] x3[n] 1. x1[n] x3[n] x2[n]
2. x2[n] x1[n] x3[n] 3. x2[n] x3[n] x1[n]
4. x3[n] x1[n] x2[n] 5. x3[n] x2[n] x1[n]
Relation Between CT and DT Frequencies
If a CT signal x(t) = cosωt is sampled at times t = nT , the resulting
DT signal is x[n] = cos Ωn where
Ω = ωT .
If we restrict DT frequencies to the range 0 ≤ Ω ≤ π, then the
corresponding CT frequencies are in the range 0 ≤ ω ≤ ωN where
ωN = π
T
and
fN = ωN2π = 1
2T = 12fs
where fN is the Nyquist frequency, which is half the sample rate fs.
Base Band Reconstruction
If all frequencies in a CT signal are less than the Nyquist frequency,
then we can reconstruct the original CT signal perfectly by discarding
frequencies in the reconstruction that exceed the Nyquist frequency.
This is called base-band reconstruction.
Anti-Aliasing
If there are frequencies in the CT signal that are greater than the
Nyquist frequency, then these will alias to frequencies in the base
band that have nothing to do with the original frequency.
These should be removed before sampling.
Anti-Aliasing Demonstration
Sampling Music
ωs = 2πT
= 2πfs
• fs = 11 kHz without anti-aliasing
• fs = 11 kHz with anti-aliasing
• fs = 5.5 kHz without anti-aliasing
• fs = 5.5 kHz with anti-aliasing
• fs = 2.8 kHz without anti-aliasing
• fs = 2.8 kHz with anti-aliasing
J.S. Bach, Sonata No. 1 in G minor Mvmt. IV. Presto
Nathan Milstein, violin
Quantization
The information content of a signal scales not only with sample rate
but also with the number of bits used to represent each sample.
11
0
0
1
1Input voltage
Outputvoltage 2 bits 3 bits 4 bits
00
01
10
0 0.5 11
0
1
Time (second)0 0.5 1
Time (second)0 0.5 1
Time (second)
1 0 1Input voltage
1 0 1Input voltage
Bit rate = (# bits/sample)×(# samples/sec)
Check Yourself
We hear sounds that range in amplitude from 1,000,000 to 1.
How many bits are needed to represent this range?
1. 5 bits
2. 10 bits
3. 20 bits
4. 30 bits
5. 40 bits
Check Yourself
How many bits are needed to represent 1,000,000:1?
bits range
1 22 43 84 165 326 647 1288 2569 512
10 1, 02411 2, 04812 4, 09613 8, 19214 16, 38415 32, 76816 65, 53617 131, 07218 262, 14419 524, 28820 1, 048, 576
Check Yourself
We hear sounds that range in amplitude from 1,000,000 to 1.
How many bits are needed to represent this range? 3
1. 5 bits
2. 10 bits
3. 20 bits
4. 30 bits
5. 40 bits
Quantization Demonstration
Quantizing Music
• 16 bits/sample
• 8 bits/sample
• 6 bits/sample
• 4 bits/sample
• 3 bits/sample
• 2 bit/sample
J.S. Bach, Sonata No. 1 in G minor Mvmt. IV. Presto
Nathan Milstein, violin
Quantization Demonstration
Quantizing Music
• 16 bits/sample
• 8 bits/sample
• 6 bits/sample
• 4 bits/sample
• 3 bits/sample
• 2 bit/sample
J.S. Bach, Sonata No. 1 in G minor Mvmt. IV. Presto
Nathan Milstein, violin
Quantization Demonstration
Quantizing Music
• 16 bits/sample
• 8 bits/sample
• 6 bits/sample
• 4 bits/sample
• 3 bits/sample
• 2 bit/sample
J.S. Bach, Sonata No. 1 in G minor Mvmt. IV. Presto
Nathan Milstein, violin
Quantization Demonstration
Quantizing Music
• 16 bits/sample
• 8 bits/sample
• 6 bits/sample
• 4 bits/sample
• 3 bits/sample
• 2 bit/sample
J.S. Bach, Sonata No. 1 in G minor Mvmt. IV. Presto
Nathan Milstein, violin
Quantization Demonstration
Quantizing Music
• 16 bits/sample
• 8 bits/sample
• 6 bits/sample
• 4 bits/sample
• 3 bits/sample
• 2 bit/sample
J.S. Bach, Sonata No. 1 in G minor Mvmt. IV. Presto
Nathan Milstein, violin
Quantization Demonstration
Quantizing Music
• 16 bits/sample
• 8 bits/sample
• 6 bits/sample
• 4 bits/sample
• 3 bits/sample
• 2 bit/sample
J.S. Bach, Sonata No. 1 in G minor Mvmt. IV. Presto
Nathan Milstein, violin
Quantization Demonstration
Quantizing Music
• 16 bits/sample
• 8 bits/sample
• 6 bits/sample
• 4 bits/sample
• 3 bits/sample
• 2 bit/sample
J.S. Bach, Sonata No. 1 in G minor Mvmt. IV. Presto
Nathan Milstein, violin
Quantization Demonstration
Quantizing Music
• 16 bits/sample
• 8 bits/sample
• 6 bits/sample
• 4 bits/sample
• 3 bits/sample
• 2 bit/sample
J.S. Bach, Sonata No. 1 in G minor Mvmt. IV. Presto
Nathan Milstein, violin
Quantizing Images
Converting an image from a continuous representation to a discrete
representation involves the same sort of issues.
This image has 280× 280 pixels, with brightness quantized to 8 bits.
Quantizing Images
8 bit image 7 bit image
Quantizing Images
8 bit image 6 bit image
Quantizing Images
8 bit image 5 bit image
Quantizing Images
8 bit image 4 bit image
Quantizing Images
8 bit image 3 bit image
Quantizing Images
8 bit image 2 bit image
Quantizing Images
8 bit image 1 bit image
Check Yourself
What is the most objectionable artifact of coarse quantization?
8 bit image 4 bit image
Dithering
One very annoying artifact is banding caused by clustering of pixels
that quantize to the same level.
Banding can be reduced by dithering.
Dithering: adding a small amount (±12 quantum) of random noise to
the image before quantizing.
Since the noise is different for each pixel in the band, the noise
causes some of the pixels to quantize to a higher value and some to
a lower. But the average value of the brightness is preserved.
Quantizing Images with Dither
7 bit image 7 bits with dither
Quantizing Images with Dither
6 bit image 6 bits with dither
Quantizing Images with Dither
5 bit image 5 bits with dither
Quantizing Images with Dither
4 bit image 4 bits with dither
Quantizing Images with Dither
3 bit image 3 bits with dither
Quantizing Images with Dither
2 bit image 2 bits with dither
Quantizing Images with Dither
1 bit image 1 bit with dither
Check Yourself
What is the most objectionable artifact of dithering?
3 bit image 3 bit dithered image
Check Yourself
What is the most objectionable artifact of dithering?
One annoying feature of dithering is that it adds noise.
Quantization Schemes
Example: slowly changing backgrounds.
Quantization: y = Q(x)
Quantization with dither: y = Q(x+ n)
Check Yourself
What is the most objectionable artifact of dithering?
One annoying feature of dithering is that it adds noise.
Robert’s technique: add a small amount (±12 quantum) of random
noise before quantizing, then subtract that same amount of random
noise.
Quantization Schemes
Example: slowly changing backgrounds.
Quantization: y = Q(x)
Quantization with dither: y = Q(x+ n)
Quantization with Robert’s technique: y = Q(x+ n)− n
Quantizing Images with Robert’s Method
7 bits with dither 7 bits with Robert’s method
Quantizing Images with Robert’s Method
6 bits with dither 6 bits with Robert’s method
Quantizing Images with Robert’s Method
5 bits with dither 5 bits with Robert’s method
Quantizing Images with Robert’s Method
4 bits with dither 4 bits with Robert’s method
Quantizing Images with Robert’s Method
3 bits with dither 3 bits with Robert’s method
Quantizing Images with Robert’s Method
2 bits with dither 2 bits with Robert’s method
Quantizing Images with Robert’s Method
1 bits with dither 1 bit with Robert’s method
Quantizing Images: 3 bits
8 bits 3 bits
dither Robert’s
Quantizing Images: 2 bits
8 bits 2 bits
dither Robert’s
Quantizing Images: 1 bit
8 bits 1 bit
dither Robert’s