At each sample the oldest value in the window is replaced with the new value and it is checked if the new value affects the median, if so a new value for the median is selected.
Diff: filter.h
- Revision:
- 0:9bd415456089
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/filter.h Fri Jan 31 10:36:45 2014 +0000 @@ -0,0 +1,24 @@ +#ifndef FILTER_H +#define FILTER_H + +class filter { +public: + virtual float process(float in) { + return in; + } +}; + +class medianFilter: public filter { + int N; + float *val; + bool *big; + int med, i; + float median; + int findmax(); + int findmin(); +public: + medianFilter(int window = 3); //every window >= 1 is allowed but the behaviour for even window sizes is not well defined + virtual float process(float); +}; + +#endif \ No newline at end of file