jmiskovic / dejitter

Simple adaptive filter for removing noise from 1D signal

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

dejitter

A simple and fast filter that removes jitter from input signal. It uses exponential smoothing, with its smoothing factor being continuously adapted to input signal. If the input signal is changing slowly it will be more heavily filtered, and fast-changing signal will be tracked faster with less lag.

The filter can be applied to object coordinates that contain jitter/noise. Stationary object will be tracked percisely, while fast object will be tracked with tiny amount of lag. Two parameters (cutoff frequency and beta) need to be tuned to get the desired results.

cutoff, beta = 1e-3, 4e-4
filter = require('dejitter')(cutoff, beta)

-- feed the next sample into the filter
output = filter(time, input)
-- output will be numerically close to input, but smoothed out over time

cutoff parameter controls filtering frequency. Low value will cut more jitter from input, but also introduces lag. beta parameter affects speed of adaptivity. Higher values will lower the lag more agressively.

The algorithm is 1€ Filter as elaborated in article. There is also an alternative Lua implementation here.

The main.lua contains a simple demo to be used with LÖVE interpreter. Input signal is sine wave with superimposed noise. The cutoff and beta are controlled by mouse position. For demo the whole signal is re-filtered on each frame, while in practice each frame would process just a single input sample.

About

Simple adaptive filter for removing noise from 1D signal

License:MIT License


Languages

Language:Lua 100.0%