Browse Source

APP_Framework/Framework/:complete sliding window mean_filter

pull/9/head
chunyexixiaoyu 11 months ago
parent
commit
c251937f9f
  1. 25
      APP_Framework/Framework/knowing/filter/mean_filter/sliding_window_mean_filter.c
  2. 10
      APP_Framework/Framework/knowing/filter/mean_filter/sliding_window_mean_filter.h

25
APP_Framework/Framework/knowing/filter/mean_filter/sliding_window_mean_filter.c

@ -1 +1,26 @@
#include <sliding_window_mean_filter.h>
void SlidingWindowsMeanFliterInit(SlidingWindowsHander * hander,unsigned int window_len)
{
hander->window_len = window_len;
hander->sumlast = 0;
InitQueue(&(hander->window_queue));
}
int SlidingWindowsMeanFliterFun(SlidingWindowsHander * hander,int newvalue)
{
int headtemf = 0;
if(QueueLength(&(hander->window_queue)) < hander->window_len)
{
EnQueue(&(hander->window_queue),newvalue);
hander->sumlast = hander->sumlast + newvalue;
return (int)((hander->sumlast)/(QueueLength(&(hander->window_queue))));
}
else
{
DeQueue(&(hander->window_queue),&headtemf);
hander->sumlast = hander->sumlast - headtemf + newvalue;
EnQueue(&(hander->window_queue),newvalue);
return (int)((hander->sumlast)/(hander->window_len));
}
}

10
APP_Framework/Framework/knowing/filter/mean_filter/sliding_window_mean_filter.h

@ -2,4 +2,14 @@
#define _SLIDING_WINDOW_MEAN_FILTER_H
#include <queue.h>
typedef struct
{
SqQueue window_queue;
unsigned int window_len; //the window_len value must less than MAXSIZE 1024
long long int sumlast;
}SlidingWindowsHander;
void SlidingWindowsMeanFliterInit(SlidingWindowsHander * hander,unsigned int window_len);
int SlidingWindowsMeanFliterFun(SlidingWindowsHander * hander,int newvalue);
#endif
Loading…
Cancel
Save