Pixel Sampling Lab

how sampling rate changes what detail survives

Loading interactive simulation...

wagon-wheel effect, but for pixels 🖖

Too slow a sampling rate moves detail rather than losing it. Load Aliasing: sixteen cycles sampled eighteen times come back as two, because |16 − 18| = 2. Load the checker preset and twelve cycles sampled fourteen times also come back as two. Two different patterns, indistinguishable once sampled. The sensor is not seeing less detail; it is seeing the wrong detail.

The two-samples-per-cycle rule 🖖

To capture a wave faithfully, you must sample it more than twice per cycle — that threshold is the Nyquist limit, half the sampling rate Fs. Below it the samples still land somewhere, but they no longer describe the original; the shape you rebuild is an impostor. Push freq above Fs/2 here and watch the yellow reconstruction detach from the green source.

Why CD audio runs at 44,100 Hz 🖖

Human hearing tops out near 20 kHz, so Nyquist demands a sampling rate above 40 kHz — but why the oddly specific 44,100? Early digital audio was stored on video tape: three samples per active line, 245 lines at 60 fields (NTSC) or 294 lines at 50 fields (PAL) both land on exactly 44,100 samples per second. A hearing limit met a videotape format, and the number stuck.

ONE STAGE OF A CHAIN — WHAT ARRIVES, WHAT LEAVES, WHAT BREAKS DOWNSTREAM

Where This Sits In The Encoding Pipeline

A video encoder is not one algorithm but eight stages in a fixed order, and the order is not arbitrary: each stage exists because the one before it made its job possible. This tool models one of them. The chain below links to the other seven.

Pixel Sampling Lab — turns a continuous image into a grid of pixels, and fixes what detail can never be recovered afterwards

What arrives
A continuous optical image on the sensor. Infinite detail, no pixels yet.
What leaves
A grid of samples at one fixed spatial resolution.
What the next stage assumes
Every later stage assumes this grid is already a fair record of the scene. Not one of them can put detail back.
What goes wrong here
Sample below twice the finest detail present and that detail does not simply vanish — it comes back as a false coarse pattern that was never in the scene. Aliasing is baked in before the encoder is reached, and no bitrate undoes it.

Problem solved in full

  1. The boundary for a 10-cycle pattern sampled 22 times 5 steps

    A 10-cycle pattern sampled 22 times is safe; sampled 18 times it comes back as 8. Work out where the boundary is, and what the signal turns into on the wrong side of it.

    1. The sampling theorem sets one condition: the rate must exceed twice the highest frequency present. Here that means anything above 20.

    2. Twenty-two samples for ten cycles is 2.2 per cycle. It clears the bound, so the original is recoverable in principle — though only just, and with no margin for anything higher hiding in the signal.

    3. Below the bound the signal does not degrade, it changes identity. Sampling at 18 makes the 10-cycle pattern indistinguishable from an 8-cycle one, and the reconstruction returns the 8.

    4. That is aliasing, and the word is precise: the high frequency does not vanish, it adopts a false name and returns as something the system will faithfully reproduce.

    5. The bound is strict rather than inclusive. Sampling at exactly 20 can land on every zero crossing and record nothing at all — equality is not enough.

    Answer

    The tool prints a source frequency of 10, a rate of 22 and 2.2 samples per cycle. The consequence is why every camera and sound card filters before it samples rather than after: once a frequency has aliased, it is a legitimate low frequency in the data and no later processing can distinguish it from one that was really there. Drop the rate to 18 and watch the reconstruction return a slower wave that the sampler has no way of knowing is wrong — moiré in a photograph is the same effect in two dimensions.

References (1)

Example problems

  • oversampled sine - Six cycles read 36 times is six samples per cycle, three times what the rule demands. The reconstruction sits on top of the source.
  • near nyquist - Ten cycles read 22 times is 2.2 samples per cycle, just above the two the rule requires: Nyquist sits at 11 and the signal at 10. It works, with nothing to spare.
  • aliasing case - Sixteen cycles read 18 times come back as two, because |16 - 18| = 2. Eight times too low, from a rate only slightly too slow.
  • checker moire - Twelve cycles read 14 times also come back as two - the same answer as Aliasing, from a different pattern at a different rate. The samples cannot tell you which you started with.