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:
- Kerneels Bezuidenhout 
- Date:
- 2016-09-26
- Revision:
- 1:7e434a01533c
- Parent:
- 0:49e6de85e2fb
- Child:
- 2:269c66e647f8
File content as of revision 1:7e434a01533c:
#include "MedianFilter.hpp"
MedianFilter::MedianFilter(int size)
{
  _size = size;
  _n = 0;
}
float MedianFilter::Process(float val)
{
  if( _n < size )
  {
    _n++;
    _window.push_back(val);
  }
  else
  {
    _window.pop_front();
    _window.push_back(val);
  }
  deque<float> _temp(_window);
  sor(_temp.begin(), temp.end());
  return _temp[n/2];
}