ENع
←Aliasing
Lesson 10 · Sampling and conversion

Aliasing: the wagon-wheel effect

12 min10 steps5 questionsBeginner
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".

You'll learn to

Tick what you feel confident about. These self-checks do not affect your lesson score.

Fig 10 · Interactive
01 / 10

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 real
Loading figure…
or ← →
Read the lesson step by step
  1. 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 real
  2. A 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.71
  3. Slow 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"
  4. 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.71
  5. The 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)
  6. 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 Hz
  7. At 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)
  8. 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 Hz
  9. Check 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)
  10. 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

Quiz Unlocks after the last step.