Smoothing filter

Moving average

The simplest thing that works

A centred mean of the frames around each one. It is the best filter there is at reducing random noise in the time domain, and among the worst in the frequency domain — both halves of that are worth knowing.

Noise remaining
1.11° of 2.34°
Peak flattening
0.2–0.6°
Phase lag
0 frames
Frame rate needed
No

Measured on our own test signals at 24fps: a clean sine wave, that wave with ±4° of random noise, and that wave with one frame knocked 108° out of place. These describe how the filter behaves — they are not a validation of markerless measurement against marker-based capture.

How it works

Add up the frames in the window, divide by how many there were, and that is the value. There is nothing else to it, which is the point: anyone can reproduce it, in any tool, and get the same answer.

For reducing random noise per frame of window it cannot be beaten. What it cannot do is separate frequencies cleanly — it lets through things a low-pass filter of the same width would have stopped.

Reach for it when

  • Someone else has to be able to reproduce what you did, in a spreadsheet, without a signal-processing library.
  • You want the most noise reduction for the shortest window.
  • The exact height of a peak is not what you are reporting.

What it costs

It flattens peaks — measurably, up to 0.6° on our test signal — so a range read off it comes out slightly narrow. If the peaks are the measurement, use Savitzky–Golay instead; it costs almost nothing to switch.

What we actually run

So the page and the code say the same thing.

  • Centred mean, shortened at the ends of a run rather than padded.
  • Windows of roughly 0.07s, 0.13s and 0.25s, scaled to the clip's own frame rate.

The research behind it

  1. Smith, S. W. (1997). The Scientist and Engineer's Guide to Digital Signal Processing, ch. 15. California Technical Publishing — free to read at dspguide.com/ch15.htm.

    Shows that the moving average is the best filter there is at reducing random noise in the time domain, and among the worst in the frequency domain. Both halves matter here.

  2. Hamming, R. W. (1998). Digital Filters (3rd ed.). Dover Publications.

    On what averaging actually does to a signal, from someone unusually honest about the cost of the simple choice.

The other four

Filtering is on Pro and above.