1
Aliasing & Antialiasing
© 2019 School of Information Technology and Electrical Engineering at The University of Queensland
TexPoint fonts used in EMF.
Read the TexPoint manual before you delete this box.: AAAAA
http://elec3004.com
Lecture Schedule:
15 March 2019 - ELEC 3004: Systems 2
Week Date Lecture Title
1 27-Feb Introduction
1-Mar Systems Overview
2 6-Mar Systems as Maps & Signals as Vectors
8-Mar Systems: Linear Differential Systems
3 13-Mar Sampling Theory & Data Acquisition
15-Mar Aliasing & Antialiasing
4 20-Mar Discrete Time Analysis & Z-Transform
22-Mar Second Order LTID (& Convolution Review)
5 27-Mar Frequency Response
29-Mar Filter Analysis
6 3-Apr Digital Filters (IIR) & Filter Analysis
5-Apr Digital Filter (FIR)
7 10-Apr Digital Windows
12-Apr FFT
8 17-Apr Active Filters & Estimation & Holiday
19-Apr
Holiday 24-Apr
26-Apr
9 1-May Introduction to Feedback Control
3-May Servoregulation/PID
10 8-May PID & State-Space
10-May State-Space Control
11 15-May Digital Control Design
17-May Stability
12 22-May State Space Control System Design
24-May Shaping the Dynamic Response
13 29-May System Identification & Information Theory
31-May Summary and Course Review
2
Follow Along Reading:
B. P. Lathi
Signal processing
and linear systems
1998
TK5102.9.L38 1998
• Chapter 5:
Sampling
– § 5.1 The Sampling Theorem
– § 5.2 Numerical Computation of
Fourier Transform: The Discrete
Fourier Transform (DFT)
Also:
– § 4.6 Signal Energy
15 March 2019 - ELEC 3004: Systems 3
• The Nyquist criterion states:
To prevent aliasing, a bandlimited signal of bandwidth wB
rad/s must be sampled at a rate greater than 2wB rad/s
–ws > 2wB
Recap: Sampling Theorem
Note: this is a > sign not a
Also note: Most real world signals require band-limiting
with a lowpass (anti-aliasing) filter
15 March 2019 - ELEC 3004: Systems 4
3
• Samples are like snacks – You don’t just take one
• Thus, by definition, sampling is a sequence
• And if we assume a fixed sample Period “𝑇”
Then it is a periodic sequence
• Any periodic sequence has a frequency
• A nice tool for mathematically modelling frequencies is the
Fourier Transform
Sampling & The Fourier Transform
ELEC 3004: Systems 15 March 2019 - 5
Recall: Fourier Transform & Fourier Transform Tables
ELEC 3004: Systems 15 March 2019 - 6
Ref: Lathi, p. 252
4
Fourier Transform Pairs [2]
ELEC 3004: Systems 15 March 2019 - 7
Ref: Analog Devices, DSP Book, Ch. 11, p. 217
Fourier Transform Pairs [3]
ELEC 3004: Systems 15 March 2019 - 8
• 𝛿 𝑡 ⇔ 1 𝑓
• Shifted 𝛿
• 1 𝑡 ⇔ 𝛿(𝑓)
5
Fourier Transform Pairs [4]
ELEC 3004: Systems 15 March 2019 - 9
• Shifted 𝛿
• cos 2𝜋𝑓0𝑡 ⇔1
2 𝛿 𝑓 − 𝑓0 + 𝛿 𝑓 + 𝑓0
• Duality:
-10 -8 -6 -4 -2 0 2 4 6 8 10 0
0.2
0.4
0.6
0.8
1
Pulse width = 1
x(t
)
time (t)
-20 -5 0 5 20 -0.5
0
0.5
1
X(w
)
Angular frequency (w)
rect(t)
sinc(w/2)
Time limited
Infinite bandwidth
15 March 2019 - ELEC 3004: Systems 10
6
-10 -8 -6 -4 -2 0 2 4 6 8 10 0
0.2
0.4
0.6
0.8
1
Pulse width = 2
x(t
)
time (t)
-10 -5 0 5 10 -0.5
0
0.5
1
1.5
2
X(w
)
Angular frequency (w)
rect(t/2)
2 sinc(w/)
Parseval’s Theorem
15 March 2019 - ELEC 3004: Systems 11
-10 -8 -6 -4 -2 0 2 4 6 8 10 0
0.2
0.4
0.6
0.8
1
Pulse width = 4
x(t
)
time (t)
-10 -5 0 5 10 -1
0
1
2
3
4
X(w
)
Angular frequency (w)
rect(t/4)
4 sinc(2w/)
15 March 2019 - ELEC 3004: Systems 12
7
-10 -8 -6 -4 -2 0 2 4 6 8 10 0
0.2
0.4
0.6
0.8
1
Pulse width = 8
x(t
)
time (t)
-10 -5 0 5 10 -2
0
2
4
6
8
X(w
)
Angular frequency (w)
rect(t/8)
8 sinc(4w/)
15 March 2019 - ELEC 3004: Systems 13
-40 -30 -20 -10 0 10 20 30 40 -0.25
0
0.5
1
Symmetry: F{sinc(t/2)} = 2 rect(-w)
x(t
)
time (t)
-5 -4 -3 -2 -1 0 1 2 3 4 5 0
2
X(w
)
Angular frequency (w)
2 rect(-w)
sinc(t/2)
Infinite time
Finite bandwidth
‘Ideal’ Lowpass filter 15 March 2019 - ELEC 3004: Systems 14
8
15 March 2019 - ELEC 3004: Systems 16
• Frequency domain: multiply by ideal LPF – ideal LPF: ‘rect’ function (gain t, cut off wc) – removes replica spectrums, leaves original
• Time domain: this is equivalent to – convolution with ‘sinc’ function – as F
-1{t rect(w/wc)} = t wc sinc(wct/)
– i.e., weighted sinc on every sample
• Normally, wc = ws/2
Time Domain Analysis of Reconstruction
n
ccr
tntwtwtnxtx
)(sinc)()(
15 March 2019 - ELEC 3004: Systems 17
9
• Whittaker–Shannon interpolation formula
Reconstruction
15 March 2019 - ELEC 3004: Systems 18
Time Domain Analysis of Reconstruction
• Frequency domain: multiply by ideal LPF – ideal LPF: ‘rect’ function (gain t, cut off wc) – removes replica spectrums, leaves original
• Time domain: this is equivalent to – convolution with ‘sinc’ function – as F
-1{t rect(w/wc)} = t wc sinc(wct/)
– i.e., weighted sinc on every sample
• Normally, wc = ws/2
Why 𝑠𝑖𝑛𝑐?
n
ccr
tntwtwtnxtx
)(sinc)()(
15 March 2019 - ELEC 3004: Systems 19
10
Zero Order Hold (ZOH)
ZOH impulse response
ZOH amplitude response
ZOH phase response
15 March 2019 - ELEC 3004: Systems 20
• Zero-Order Hold [ZOH]
Reconstruction
15 March 2019 - ELEC 3004: Systems 21
11
• Whittaker–Shannon interpolation formula
Reconstruction
15 March 2019 - ELEC 3004: Systems 22
Ideal 𝑠𝑖𝑛𝑐 Interpolation of sample values [0 0 0.75 1 0.5 0 0]
-4 -3 -2 -1 0 1 2 3 4
-0.2
0
0.2
0.4
0.6
0.8
1
Sample
Valu
e
reconstructed signal xr(t)
15 March 2019 - ELEC 3004: Systems 23
12
‘staircase’ output from D/A converter (ZOH)
0 1 2 3 4 5 6 7 8 9 10 0
2
4
6
8
10
12
14
16
Time (sec)
Am
plit
ud
e (
V)
output samples
D/A output
15 March 2019 - ELEC 3004: Systems 24
Smooth output from reconstruction filter
0 2 4 6 8 10 12 2
4
6
8
10
12
14
16
Time (sec)
Am
plit
ud
e (
V)
D/A output
Reconstruction filter output
15 March 2019 - ELEC 3004: Systems 25
13
Example: error due to signal quantisation
0 1 2 3 4 5 6 7 8 9 10 0
2
4
6
8
10
12
14
16
Sample number
Am
plit
ud
e (
V)
original signal x(t) quantised samples xq(t)
15 March 2019 - ELEC 3004: Systems 26
%% Sample PSD
%% Set Values
f=1;
phi=0;
fs=1e2;
t0=0;
tf=1;
%% Generate Signal
t=linspace(t0,tf,(fs*(tf-t0)));
x1=cos(2*pi*f*t + phi);
figure(10); plot(t, x1);
%% PSD
[p_x1, f_x1] = pwelch(x1,[],[],[],fs);
figure(20); plot(f_x1, pow2db(p_x1));
xlabel('Frequency (Hz)');
ylabel('Magnitude (dB)');
%% PSD (Centered)
[p_x1, f_x1] = pwelch(x1,[],[],[],fs, 'centered','power');
figure(30); plot(f_x1, pow2db(p_x1));
xlabel('Frequency (Hz)');
ylabel('Magnitude (dB)');
Matlab Example
15 March 2019 - ELEC 3004: Systems 28
16
Sampling & Aliasing
15 March 2019 - ELEC 3004: Systems 33
Overview (i.e. today we are going to learn …)
• Aliasing
• Spectral Folding
• Anti-Aliasing
– Low-pass filtering of
signals so as to keep things
band limited
15 March 2019 - ELEC 3004: Systems 34
17
• Aliasing - through sampling, two entirely different analog
sinusoids take on the same “discrete time” identity
For 𝑓[𝑘] = cos(Ω𝑘, ) Ω = 𝜔𝑇:
The period has to be less than Fh (highest frequency):
Thus:
ωf: aliased frequency:
Alliasing
15 March 2019 - ELEC 3004: Systems 35
Ex: Moire Effects
Source: Wikimedia https://en.wikipedia.org/wiki/Aliasing#/media/File:Moire_pattern_of_bricks.jpg (and aliased)
15 March 2019 - ELEC 3004: Systems 36
18
Aliasing: Another view of this
15 March 2019 - ELEC 3004: Systems 37
if
then “Folding” or “aliasing”:
Spectrum Overlap
frequency
15 March 2019 - ELEC 3004: Systems 38
19
Original Spectrum
w -wm wm
Replica spectrums
overlap with original
(and each other)
This is Aliasing
w
… …
Fourier transform of impulse train (sampling signal)
0 2/t 4/t 6/t
…
Amplitude spectrum of sampled signal
w
…
Original Replica 1 Replica 2 … 15 March 2019 - ELEC 3004: Systems 39
Original Spectrum
15 March 2019 - ELEC 3004: Systems 40
20
Rotating wheel and peg
Top
View
Front
View
Need both top and front
view to determine rotation
Another way to see Aliasing Too!
15 March 2019 - ELEC 3004: Systems 41
Temporal Aliasing
90o clockwise rotation/frame
clockwise rotation perceived
270o clockwise rotation/frame
(90o) anticlockwise rotation
perceived i.e., aliasing
Require LPF to ‘blur’ motion
15 March 2019 - ELEC 3004: Systems 42
21
• Non-ideal filter
𝑤𝑐 =𝑤𝑠
2
• Filter usually 4th – 6th order (e.g., Butterworth) – so frequencies > wc may still be present
– not higher order as phase response gets worse
• Luckily, most real signals – are lowpass in nature
• signal power reduces with increasing frequency
– e.g., speech naturally bandlimited (say < 8KHz)
– Natural signals have a ~1
𝑓 spectrum
– so, in practice aliasing is not (usually) a problem
Practical Anti-aliasing Filter
15 March 2019 - ELEC 3004: Systems 43
Amplitude spectrum of sampled signal
Due to overlapping
replicas (aliasing)
the reconstruction
filter cannot recover
the original spectrum
Reconstruction filter (ideal lowpass filter)
w -wc wc = wm
Spectrum of reconstructed signal
w -wm wm
…
w
…
Original Replica 1 Replica 2 …
sampled signal
spectrum
The effect of aliasing is
that higher frequencies
of “alias to” (appear as)
lower frequencies 15 March 2019 - ELEC 3004: Systems 44
22
Mathematics of Sampling and Reconstruction
DSP Ideal
LPF
x(t) xc(t) y(t)
Impulse train
T(t)= (t - nt)
… … t
Sampling frequency fs = 1/t
Gain
fc Freq
1
0
Cut-off frequency = fc
reconstruction sampling
15 March 2019 - ELEC 3004: Systems 45
• Consider the case where the DSP performs no filtering
operations – i.e., only passes xc(t) to the reconstruction filter
• To understand we need to look at the frequency domain
• Sampling: we know – multiplication in time convolution in frequency
– F{x(t)} = X(w)
– F{T(t)} = (w - 2n/t),
– i.e., an impulse train in the frequency domain
Frequency Domain Analysis of Sampling
15 March 2019 - ELEC 3004: Systems 46
23
Frequency Space
15 March 2019 - ELEC 3004: Systems 47
• In the frequency domain we have
Frequency Domain Analysis of Sampling
n
n
c
t
nwX
t
t
nw
twXwX
21
22*)(
2
1)(
Let’s look at an example where X(w) is triangular function
with maximum frequency wm rad/s
being sampled by an impulse train, of frequency ws rad/s
Remember
convolution with
an impulse?
Same idea for an
impulse train
15 March 2019 - ELEC 3004: Systems 48
24
• In this example it was possible to recover the original signal
from the discrete-time samples
• But is this always the case?
• Consider an example where the sampling frequency ws is
reduced – i.e., t is increased
Sampling Frequency
15 March 2019 - ELEC 3004: Systems 49
Fourier transform of original signal X(ω) (signal spectrum)
w
… …
Fourier transform of impulse train T(/2) (sampling signal)
0 ws = 2/t 4/t
Original spectrum
convolved with
spectrum of
impulse train …
Fourier transform of sampled signal
w
…
Original Replica 1 Replica 2
1/t
15 March 2019 - ELEC 3004: Systems 50
25
Spectrum of sampled signal
Spectrum of reconstructed signal
w -wm wm
Reconstruction filter
removes the replica
spectrums & leaves
only the original
Reconstruction filter (ideal lowpass filter)
w -wc wc = wm
t
…
w
…
Original Replica 1 Replica 2
1/t
15 March 2019 - ELEC 3004: Systems 51
Sampled Spectrum ws > 2wm
w -wm wm ws
orignal replica 1 …
…
LPF
original freq recovered
Sampled Spectrum ws < 2wm
w -wm wmws
…
orignal …
replica 1
LPF
Original and replica spectrums overlap
Lower frequency
recovered (ws – wm)
15 March 2019 - ELEC 3004: Systems 52
26
Taking Advantage of the Folding
15 March 2019 - ELEC 3004: Systems 53
• Digital Systems
• Review: – Chapter 8 of Lathi
• A signal has many signals
[Unless it’s bandlimited. Then there is the one ω]
Next Time…
15 March 2019 - ELEC 3004: Systems 54
27
Data Acquisition (A/D Conversion)
15 March 2019 - ELEC 3004: Systems 55
Representation of Signal
• Time Discretization • Digitization
0 5 10 150
100
200
300
400
500
600
time (s)
Ex
pec
ted
sig
nal (m
V)
Coarse time discretization
True signal
Discrete time sampled points
0 5 10 150
100
200
300
400
500
600
time (s)
Ex
pec
ted
sig
nal
(mV
)
Coarse signal digitization
True signal
Digitization
15 March 2019 - ELEC 3004: Systems 56
28
• Analogue to digital converter (A/D) – Calculates nearest binary number to x(nt)
• xq[n] = q(x(nt)), where q() is non-linear rounding fctn
– output modeled as xq[n] = x(nt) + e[n]
• Approximation process – therefore, loss of information (unrecoverable) – known as ‘quantisation noise’ (e[n]) – error reduced as number of bits in A/D increased
• i.e., x, quantisation step size reduces
Quantisation
2][
xne
15 March 2019 - ELEC 3004: Systems 57
Input-output for 4-bit quantiser (two’s compliment)
Analogue
Digital
7 0111
6 0110
5 0101
4 0100
3 0011
2 0010
1 0001
0 0000
-1 1111
-2 1110
-3 1101
-4 1100
-5 1011
-6 1010
-7 1000
x
quantisation
step size
12
2
m
Ax
where A = max amplitude
m = no. quantisation bits
15 March 2019 - ELEC 3004: Systems 58
29
• To estimate SQNR we assume – e[n] is uncorrelated to signal and is a
– uniform random process
• assumptions not always correct! – not the only assumptions we could make…
• Also known a ‘Dynamic range’ (RD) – expressed in decibels (dB)
– ratio of power of largest signal to smallest (noise)
Signal to Quantisation Noise
noise
signal
DP
PR 10log10
15 March 2019 - ELEC 3004: Systems 59
Need to estimate:
1. Noise power – uniform random process: Pnoise = x2/12
2. Signal power – (at least) two possible assumptions 1. sinusoidal: Psignal = A2/2 2. zero mean Gaussian process: Psignal = 2
• Note: as A/3: Psignal A2/9
• where 2 = variance, A = signal amplitude
Dynamic Range
Regardless of assumptions: RD increases by 6dB
for every bit that is added to the quantiser
1 extra bit halves x
i.e., 20log10(1/2) = 6dB
15 March 2019 - ELEC 3004: Systems 60
30
-6 -4 -2 0 2 4 6
-1
-0.5
0
0.5
1
t
sin(10 t) + 0.1 sin(100 t)
-6 -4 -2 0 2 4 6
-1
-0.5
0
0.5
1
t
sin(10 t) + 0.1 sin(100 t)
Derivatives magnify noise!
•
•
•
•
-6 -4 -2 0 2 4 6
-20
-15
-10
-5
0
5
10
15
20
t
10 cos(10 t) + 10 cos(100 t)-6 -4 -2 0 2 4 6
-10
-5
0
5
10
t
10 cos(10 t)
15 March 2019 - ELEC 3004: Systems 61
• Analogue output y(t) is – convolution of output samples y(nt) with hZOH(t)
D/A Converter
2/
)2/sin(
2exp)(
otherwise,0
0,1)(
)()()(
tw
twtjwtwH
ttth
tnthtnyty
ZOH
ZOH
ZOH
n
D/A is lowpass filter with sinc type frequency response
It does not completely remove the replica spectrums
Therefore, additional reconstruction filter required
15 March 2019 - ELEC 3004: Systems 62
31
• Impulse train sampling not realisable – sample pulses have finite width (say nanosecs)
• This produces two effects,
• Impulse train has sinc envelope in frequency domain – impulse train is square wave with small duty cycle
– Reduces amplitude of replica spectrums • smaller replicas to remove with reconstruction filter
• Averaging of signal during sample time – effective low pass filter of original signal
• can reduce aliasing, but can reduce fidelity
• negligible with most S/H
Finite Width Sampling
15 March 2019 - ELEC 3004: Systems 63
• Sample and Hold (S/H) 1. takes a sample every t seconds 2. holds that value constant until next sample
• Produces ‘staircase’ waveform, x(nt)
Practical Sampling
t
x(t)
hold for t
sample instant
x(nt)
15 March 2019 - ELEC 3004: Systems 64
32
Two stage process:
• Digital to analogue converter (D/A) – zero order hold filter
– produces ‘staircase’ analogue output
• Reconstruction filter
– non-ideal filter: 𝜔𝑐 =𝜔𝑠
2
– further reduces replica spectrums
– usually 4th – 6th order e.g., Butterworth • for acceptable phase response
Practical Reconstruction
15 March 2019 - ELEC 3004: Systems 65
• Theoretical model of Sampling – bandlimited signal (wB)
– multiplication by ideal impulse train (ws > 2wB) • convolution of frequency spectrums (creates replicas)
– Ideal lowpass filter to remove replica spectrums • wc = ws /2
• Sinc interpolation
• Practical systems – Anti-aliasing filter (wc < ws /2)
– A/D (S/H and quantisation)
– D/A (ZOH)
– Reconstruction filter (wc = ws /2)
Summary
Don’t confuse
theory and
practice!
15 March 2019 - ELEC 3004: Systems 66