Aliasing: the wagon-wheel effect
About this lesson
Why does a fast wheel on film seem to turn slowly, stand still or even spin backward? A camera only samples the wheel 8 times a second. Follow one red spot: at 1 turn a second the frames tell the truth, but at 7 turns a second each frame catches the wheel 315° further on, which looks exactly like 45° backward. The 7 Hz wave and a −1 Hz wave give the very same samples: the slow one is an alias. You will learn the folding rule that predicts the alias, check it in Python with numpy, and see why you must sample faster than twice the highest frequency or filter first. It builds on "Sampling: taking snapshots" and "The Nyquist rate".
A turning wheel is a signal
A wheel turns once a second: 1 turn per second is a frequency of 1 hertz (Hz). Watch one red spot. Its height above the axle rises and falls as a sine wave, x(t) = sin(2π·f·t). That is our signal.
wheel f = 1 turn per second = 1 Hz
signal x(t) = sin(2π·f·t)
height of the red spot above the axle,
in wheel radii (−1 .. +1)
t = 0 spot at "3 o'clock", height 0
t = 0.25 s spot at the top, height 1
motion in the figure: 12 times slower than realRead the lesson step by step
A turning wheel is a signal
A wheel turns once a second: 1 turn per second is a frequency of 1 hertz (Hz). Watch one red spot. Its height above the axle rises and falls as a sine wave, x(t) = sin(2π·f·t). That is our signal.
wheel f = 1 turn per second = 1 Hz signal x(t) = sin(2π·f·t) height of the red spot above the axle, in wheel radii (−1 .. +1) t = 0 spot at "3 o'clock", height 0 t = 0.25 s spot at the top, height 1 motion in the figure: 12 times slower than realA camera takes samples
A camera takes 8 frames a second, one every Ts = 1/8 s = 125 ms. Each frame records the spot's height at that instant: a sample, x[n] = x(n·Ts). Between frames the camera sees nothing.
fs = 8 frames per second (the sampling rate) Ts = 1 / fs = 125 ms x[n] = x(n·Ts) = sin(2π·1·n/8) n: 0 1 2 3 x: 0.00 0.71 1.00 0.71 n: 4 5 6 7 x: 0.00 −0.71 −1.00 −0.71Slow enough: the replay is right
At 1 turn a second the spot moves 360°/8 = 45° between frames. Played back on a screen, the wheel turns forward once a second, as it really does. 1 Hz is below fs/2 = 4 Hz, the Nyquist limit.
turn per frame = 360° × f / fs = 360° × 1 / 8 = 45° (forward) Nyquist limit: fs / 2 = 4 Hz f = 1 Hz < 4 Hz -> the samples follow the real motion see the lesson "The Nyquist rate"Spin it 7 times a second
Now the wheel turns 7 times a second. The camera still takes only 8 frames a second, so between two frames the wheel turns 7/8 of a turn: 315°. Almost all of the motion happens unseen.
f = 7 Hz, fs = 8 frames per second turn per frame = 360° × 7 / 8 = 315° f = 7 Hz > fs / 2 = 4 Hz -> too fast for this camera x[n] = sin(2π·7·n/8) n: 0 1 2 3 x: 0.00 −0.71 −1.00 −0.71The wheel seems to turn backward
315° forward ends exactly where 45° backward would. Your eye links each frame to the next by the shortest turn, so on the screen the spot steps back 45° a frame: the wheel seems to turn backward once a second. This is the wagon-wheel effect.
real turn per frame 315° forward same end position 315° − 360° = −45° shortest turn (seen) 45° backward seen speed = −45° × 8 frames/s = −360° per s = −1 turn per second films of wagon wheels show the same (temporal aliasing)Two waves, the same samples
For every whole number n, sin(2π·7·n/8) = −sin(2π·n/8). So the 7 Hz wave and a slow −1 Hz wave pass through exactly the same samples. From the numbers alone nobody can tell them apart. The false, slower wave is called an alias.
sin(2π·7·n/8) = sin(2π·n − 2π·n/8) = sin(−2π·n/8) (2π·n is whole turns) = −sin(2π·n/8) 7 Hz samples: 0.00 −0.71 −1.00 −0.71 ... −1 Hz samples: 0.00 −0.71 −1.00 −0.71 ... same numbers -> −1 Hz is an alias of 7 HzAt 8 turns a second it stands still
Spin the wheel 8 times a second, the same as the frame rate. It makes exactly one whole turn between frames, so every frame finds the spot in the same place. On the screen the wheel stands still: the alias is 0 Hz.
f = fs = 8 Hz turn per frame = 360° × 8 / 8 = 360° = one whole turn x[n] = sin(2π·8·n/8) = sin(2π·n) = 0 for every n seen frequency: 8 − 8 = 0 Hz (stands still)The folding rule
The seen frequency is f − k·fs, where k is the whole number that brings it between −4 and +4 Hz. So 1 → 1, 7 → −1, 8 → 0, 9 → +1. Anything above fs/2 = 4 Hz folds back into that band.
seen f_a = f − k·fs, k a whole number, chosen so −fs/2 < f_a ≤ fs/2 true f k seen f_a 1 0 1 7 1 −1 (backward) 8 1 0 (still) 9 1 1 15 2 −1 plot: f_a against f, a saw-tooth that repeats every fs = 8 HzCheck it in Python
With numpy, sample both waves at the same 8 instants n/8 s. np.sin takes radians. np.allclose compares the two arrays and prints True: the 7 Hz samples and the −1 Hz samples are the same list of numbers.
import numpy as np n = np.arange(8) a = np.sin(2*np.pi*7*n/8) b = np.sin(-2*np.pi*n/8) np.allclose(a, b) # True >>> a.round(2) array([ 0. , -0.71, -1. , -0.71, 0. , 0.71, 1. , 0.71]) >>> np.allclose(a, b) True (Python 3 with numpy)How to avoid aliasing
Sample faster than twice the highest frequency: fs > 2·f. A 7 Hz spin needs more than 14 frames a second. If you cannot, remove frequencies above fs/2 before sampling with a low-pass anti-alias filter: the next lesson.
rule (Nyquist): fs > 2 · f_max f_max = 7 Hz -> fs > 14 frames per second f_max = 1 Hz -> fs > 2: our 8 frames/s is fine or: low-pass filter first, so nothing above fs / 2 = 4 Hz reaches the sampler (an anti-alias filter: next lesson) once aliased, the samples cannot be fixed: the 7 Hz and −1 Hz numbers are identical
5 quick questions
Choose one answer per question. You can change your choices before checking them.
01A camera takes 8 frames a second. A wheel turns 7 times a second. How far does it really turn between two frames?
360° × f / fs = 360° × 7 / 8 = 315°. That ends where a 45° backward turn would, which is why the wheel seems to go backward.
02Same camera (8 frames a second). The wheel turns 8 times a second. What do you see in the film?
It makes exactly one whole turn between frames, so every frame finds the spot in the same place: the alias is 8 − 8 = 0 Hz.
03What is an alias?
Sampled too slowly, a high frequency produces the same list of numbers as a lower frequency. From the samples alone the two cannot be told apart; the false one is the alias. (Rounding error is quantization, a different effect.)
04With fs = 8 samples a second, which frequency does a 9 Hz wave look like?
f_a = f − k·fs with k = 1: 9 − 8 = +1 Hz, which is between −4 and +4 Hz. (17 Hz is another frequency with the same samples, but it is not inside the band.)
05A signal contains frequencies up to 7 Hz. Which sampling rate avoids aliasing?
The sampling rate must be more than twice the highest frequency: fs > 2 × 7 = 14. Exactly 14 is not enough, so only 20 works here.
Glossary
- Sampling rate (fs)
- How many samples (here, camera frames) are taken per second; Ts = 1/fs is the time between them.
- Frequency (f)
- Repeats per second, in hertz (Hz). A wheel that turns 7 times a second has f = 7 Hz.
- Aliasing
- When a frequency above half the sampling rate shows up in the samples as a different, lower frequency.
- Alias
- The false frequency that gives exactly the same samples as the real one.
- Nyquist frequency (fs/2)
- Half the sampling rate. Frequencies above it fold back into the band from −fs/2 to +fs/2; it is also called the folding frequency.
- Wagon-wheel effect
- A filmed wheel that seems to turn slowly, stop or spin backward because the camera samples it too slowly: temporal aliasing.
- Anti-alias filter
- A low-pass filter placed before the sampler that removes frequencies above fs/2, so they cannot alias.
Notes and sources
- The frame rate of 8 frames a second and the speeds of 1, 7 and 8 turns a second are chosen so the numbers stay small; the same rule holds for any rate (Oppenheim & Willsky, ch. 7). Every curve and value in the figure is computed from this model.
- The wheel turns 12 times slower than the speeds in the text, so you can follow it. The screen glides each new frame by the shortest turn, which is how the eye links the frames of a film.
- The wheel has one spoke and one spot on purpose. A wheel with several identical spokes can alias in other ways too, because the camera cannot tell one spoke from the next.
- A. V. Oppenheim, A. S. Willsky, S. H. Nawab, Signals and Systems, 2nd ed., Pearson, ch. 7 Sampling (aliasing from undersampling)
- A. V. Oppenheim, R. W. Schafer, J. R. Buck, Discrete-Time Signal Processing, 2nd ed. (course text listed on MIT OCW 6.341 readings)
- MIT OpenCourseWare 6.003 Signals and Systems (D. Freeman, Fall 2011): sampling
- MIT OpenCourseWare RES.6-007 Signals and Systems (A. V. Oppenheim): sampling for analog and digital systems
- Aliasing (Wikipedia): alias frequencies |f + N·fs|, folding frequency fs/2
- Nyquist–Shannon sampling theorem (Wikipedia): B < fs/2, anti-aliasing low-pass filter
- Wagon-wheel effect (Wikipedia): in film, the effect is temporal aliasing
- NumPy documentation: numpy.sin (angles in radians)
- NumPy documentation: numpy.allclose (rtol 1e-05, atol 1e-08)
Quiz Unlocks after the last step.