Vector3 Modified
Dependents: optWingforHAPS_Eigen hexaTest_Eigen
Diff: MedianFilter.cpp
- Revision:
- 2:269c66e647f8
- Parent:
- 1:7e434a01533c
- Child:
- 3:ec86928ff12d
--- a/MedianFilter.cpp Mon Sep 26 20:45:46 2016 +0200 +++ b/MedianFilter.cpp Mon Sep 26 20:55:13 2016 +0200 @@ -4,25 +4,19 @@ { _size = size; _n = 0; + + for( float i = 0; i < _n; i++) + _window.push_back(i); } float MedianFilter::Process(float val) { - if( _n < size ) - { - _n++; - _window.push_back(val); - } - else - { - _window.pop_front(); - _window.push_back(val); - } + _window.pop_front(); + _window.push_back(val); deque<float> _temp(_window); - sor(_temp.begin(), temp.end()); + sort(_temp.begin(), temp.end()); return _temp[n/2]; - }