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.
filter.h
00001 #ifndef FILTER_H 00002 #define FILTER_H 00003 00004 class filter { 00005 public: 00006 virtual float process(float in) { 00007 return in; 00008 } 00009 }; 00010 00011 class medianFilter: public filter { 00012 int N; 00013 float *val; 00014 bool *big; 00015 int med, i; 00016 float median; 00017 int findmax(); 00018 int findmin(); 00019 public: 00020 medianFilter(int window = 3); //every window >= 1 is allowed but the behaviour for even window sizes is not well defined 00021 virtual float process(float); 00022 }; 00023 00024 #endif
Generated on Tue Jul 19 2022 22:55:40 by 1.7.2