APP_Framework/Framework/:complete sliding window mean_filter
This commit is contained in:
parent
88d7ef83d3
commit
c251937f9f
|
@ -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));
|
||||
}
|
||||
|
||||
}
|
|
@ -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…
Reference in New Issue