种简单的数字滤波算法C语言源程序Word文件下载.doc
《种简单的数字滤波算法C语言源程序Word文件下载.doc》由会员分享,可在线阅读,更多相关《种简单的数字滤波算法C语言源程序Word文件下载.doc(4页珍藏版)》请在冰点文库上搜索。
![种简单的数字滤波算法C语言源程序Word文件下载.doc](https://file1.bingdoc.com/fileroot1/2023-5/11/63b35f1e-1ce0-4b2d-8f57-fc54edd31df6/63b35f1e-1ce0-4b2d-8f57-fc54edd31df61.gif)
charvalue;
charfilter()
{
char
new_value;
new_value=get_ad();
if((new_value-value>
A)||(value-new_value>
A)
returnvalue;
returnnew_value;
}
2、中位值滤波法
N值可根据实际情况调整
排序采用冒泡法*/
#defineN
11
charvalue_buf[N];
charcount,i,j,temp;
for(count=0;
count<
N;
count++)
{
value_buf[count]=get_ad();
delay();
}
for(j=0;
j<
N-1;
j++)
for(i=0;
i<
N-j;
i++)
if(value_buf[i]>
value_buf[i+1])
temp=value_buf[i];
value_buf[i]=value_buf[i+1];
value_buf[i+1]=temp;
returnvalue_buf[(N-1)/2];
}
3、算术平均滤波法
/*
*/
#defineN12
int
sum=0;
sum+=get_ad();
return(char)(sum/N);
4、递推平均滤波法(又称滑动平均滤波法)
#defineN12
charvalue_buf[N];
chari=0;
charcount;
sum=0;
value_buf[i++]=get_ad();
if(i==N)
i=0;
N,count++)
sum=value_buf[count];
5、中位值平均滤波法(又称防脉冲干扰平均滤波法)
charcount,i,j;
for
(count=0;
for(count=1;
sum+=value[count];
return(char)(sum/(N-2));
6、限幅平均滤波法
*/
略参考子程序1、3
7、一阶滞后滤波法
/*为加快程序处理速度假定基数为100,a=0~100*/
#definea50
return(100-a)*value+a*new_value;
8、加权递推平均滤波法
/*coe数组为加权系数表,存在程序存储区。
charcodecoe[N]={1,2,3,4,5,6,7,8,9,10,11,12};
charcodesum_coe=1+2+3+4+5+6+7+8+9+10+11+12;
for(count=0,count<
sum+=value_buf[count]*coe[count];
return(char)(sum/sum_coe);
9、消抖滤波法
charcount=0;
charnew_value;
while(value!
=new_value);
count++;
if(count>
=N)
10、限幅消抖滤波法