这两天的编程涉及到这个一阶差分二阶差分的问题,
Dn =Xn - Xn-1 一阶差分
DDn =Dn - Dn-1 二阶差分
用这两种算法来处理一组的数据,处理完比较了下的, 还是没看出一阶差分处理后的图像跟不处理的图像有啥变化的,就只看到最大幅值的被削减了,大侠们有啥高见的帮我解下惑的啊,谢谢!另附上我整的一阶二阶差分的代码:
/*
if(a1 ==0xffff) //一阶差分
a1=adc_temp;
else if(a2 ==0xffff)
a2 =adc_temp;
if((a1==0xffff)||(a2==0xffff))
{;}
else
{
if(a1>a2)
{
a00 =a1 -a2;
a00 =768-a00;
}
else
{
a00 =a2 -a1;
a00 =768+a00;
}
a1 =a2;
a2 =0xffff;
adc_flag =0x01;
}
*/
if(a1 ==0xffff) //二阶差分
a1=adc_temp;
else if(a2 ==0xffff)
a2 =adc_temp;
if((a1==0xffff)||(a2==0xffff))
{;}
else
{
if(a ==0xffff)
{
if(a1>a2)
{
a =a1 -a2;
a =768-a;
}
else
{
a =a2 -a1;
a =768+a;
}
a1 =a2;
a2 =0xffff;
}
else if(a0 ==0xffff)
{
if(a1>a2)
{
a0 =a1 -a2;
a0 =768-a0;
}
else
{
a0 =a2 -a1;
a0 =768+a0;
}
a1 =a2;
a2 =0xffff;
}
if((a ==0xffff)||(a0 ==0xffff))
{;}
else
{
if(a>a0)
{
a00 =a -a0;
a00 =768 -a00;
}
else
{
a00=a0-a;
a00 =a00+768;
}
adc_flag =0x01;
a =a0;
a0 =0xffff;
}
}
a00为最终处理好的结果的,a/a0为一阶差分处理后的结果,a1/a2为一阶差分处理前由adc_temp装载的原始数据 |