Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
MedianFilter.cpp
- Committer:
- Generic
- Date:
- 2016-09-26
- Revision:
- 3:ec86928ff12d
- Parent:
- 2:269c66e647f8
File content as of revision 3:ec86928ff12d:
#include "MedianFilter.hpp"
MedianFilter::MedianFilter(int size)
{
  _size = size;  
  for( float i = 0; i < _size; i++)
    _window.push_back(i);
}
float MedianFilter::Process(float val)
{
  _window.pop_front();
  _window.push_back(val);
  deque<float> _temp(_window);
  sort(_temp.begin(), _temp.end());
  return _temp[_size/2];
}