MedianFilter Filter

template<typename T, size_t N>
struct MedianFilter

Filter using median of a sliding window.

This stateful filter maintains a sliding window and calculates the median value, propagating changes only when values are within 20% of the median to reject outliers.

Since

v0.1.0

// Example: Median filter with window of 7
Signal<float, 10, MedianFilter<float, 7>> noisy(0.0);

Note

Stateful filter. Accepts values within 20% of median.

Warning

  • Only accepts arithmetic types (integral and floating-point).

  • Window size N must be greater than 0.

Template Parameters:
typename T

Arithmetic type.

size_t N

Window size for median calculation.

Public Functions

inline bool operator()(const T &old_value, const T &new_value) const

Public Members

mutable T buffer[N] = {}
mutable size_t index = 0
mutable size_t count = 0

See Also