|
|
@ -11,8 +11,8 @@ class MedianFilter : public BaseFilter { |
|
|
|
public: |
|
|
|
|
|
|
|
virtual void reset() { |
|
|
|
double last = _data->empty() ? 0 : _data->back(); |
|
|
|
_data->clear(); |
|
|
|
double last = _data.empty() ? 0 : _data.back(); |
|
|
|
_data.clear(); |
|
|
|
add(last); |
|
|
|
} |
|
|
|
|
|
|
@ -20,13 +20,13 @@ class MedianFilter : public BaseFilter { |
|
|
|
|
|
|
|
double sum = 0; |
|
|
|
|
|
|
|
if (_data->size() > 2) { |
|
|
|
if (_data.size() > 2) { |
|
|
|
|
|
|
|
for (unsigned char i = 1; i <= _data->size() - 2; i++) { |
|
|
|
for (unsigned char i = 1; i <= _data.size() - 2; i++) { |
|
|
|
|
|
|
|
double previous = _data->at(i-1); |
|
|
|
double current = _data->at(i); |
|
|
|
double next = _data->at(i+1); |
|
|
|
double previous = _data.at(i-1); |
|
|
|
double current = _data.at(i); |
|
|
|
double next = _data.at(i+1); |
|
|
|
|
|
|
|
if (previous > current) std::swap(previous, current); |
|
|
|
if (current > next) std::swap(current, next); |
|
|
@ -36,11 +36,11 @@ class MedianFilter : public BaseFilter { |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
sum /= (_data->size() - 2); |
|
|
|
sum /= (_data.size() - 2); |
|
|
|
|
|
|
|
} else if (_data->size() > 0) { |
|
|
|
} else if (_data.size() > 0) { |
|
|
|
|
|
|
|
sum = _data->front(); |
|
|
|
sum = _data.front(); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|