#include <Filters/MedianFilter.hpp>
Class for Median Filters.
Use the parenthesis or call operator (operator()) with the next input of the filter as an argument to update the Median filter. This operator returns the next output of the filter.
The output equation is: \( y[n] = \text{median}\Big(x[n], x[n-1],\ \ldots,\ x[n-N+1]\Big) \)
| N | The number of previous values to take the median of. |
| T | The type of the input and output values of the filter. |
Definition at line 111 of file MedianFilter.hpp.
Collaboration diagram for MedianFilter< N, T >:Public Member Functions | |
| MedianFilter ()=default | |
| Construct a new Median Filter (zero initialized). More... | |
| MedianFilter (T initialValue) | |
| Construct a new Median Filter, and initialize it with the given value. More... | |
| T | operator() (T x) |
| Calculate the output \( y[n] \) for a given input \( x[n] \). More... | |
Private Attributes | |
| uint8_t | index = 0 |
| The last index in the ring buffer. More... | |
| std::array< T, N > | previousInputs = {{}} |
| A ring buffer to keep track of the N last inputs. More... | |
|
default |
Construct a new Median Filter (zero initialized).
|
inline |
Construct a new Median Filter, and initialize it with the given value.
| initialValue | Determines the initial state of the filter: \( x[-N] =\ \ldots\ = x[-2] = x[-1] = \text{initialValue} \) |
Definition at line 126 of file MedianFilter.hpp.
|
inline |
Calculate the output \( y[n] \) for a given input \( x[n] \).
\( y[n] = \text{median}\Big(x[n], x[n-1],\ \ldots,\ x[n-N+1]\Big) \)
| x | The new input \( x[n] \). |
Definition at line 140 of file MedianFilter.hpp.
|
private |
The last index in the ring buffer.
Definition at line 168 of file MedianFilter.hpp.
|
private |
A ring buffer to keep track of the N last inputs.
Definition at line 170 of file MedianFilter.hpp.