资源简介
c#实现的FIR数字滤波器,滤除50hz工频干扰;中值滤波实现滤除基线漂移
代码片段和文件信息
using System;
using System.Collections.Generic;
using System.Text;
using System.Collections;
namespace WindowsApplication2
{
class MyFirlter
{
public static short[] GetFirlterData(short[] Data)
{
short[] Result = new short[Data.Length - 90];
Queue WindowQueue=new Queue(90);
short[] WindowArray = new short[90];
int site = 0;
for (int i = 0; i < 90; i++)
{
WindowQueue.Enqueue(Data[i]);
site = i;
}
short item = 0;
while (site < Data.Length)
{
WindowQueue.CopyTo(WindowArray 0);
item = GetEachFirlterData(WindowArray);
Result[site - 89] = item;
site++;
WindowQueue.Dequeue();
WindowQueue.Enqueue(Data[site]);
}
return Result;
}
private static short GetEachFirlterData(short[] Data)
{
short Result = 0;
short h = Data[9];
short t1 = Convert.ToInt16(Data[79] - Data[0]+Data[89]);
//short t2 = Convert.ToInt16(Data[79] - Data[70]);
int t = Convert.ToInt32(Math.Pow(t1 2));
Result = Convert.ToInt16(h - t / 64);
return Result;
}
public static short[] de(short[] Data)
{
short[] Result = new short[Data.Length - 7];
Queue WindowQueue = new Queue(7);
short[] WindowArray = new short[7];
int site = 0;
for (int i = 0; i < 7; i++)
{
WindowQueue.Enqueue(Data[i]);
site = i;
}
short item = 0;
while (site < Data.Length-7)
{
WindowQueue.CopyTo(WindowArray 0);
item = ce(WindowArray);
Result[site - 6] = item;
site++;
WindowQueue.Dequeue();
WindowQueue.Enqueue(Data[site]);
}
return Result;
}
private static short ce(short[] data)
{
int j = (-data[0] + 2 * data[5] + 5 * data[4] + 4 * data[3] + 5 * data[2] + 2 * data[1] - data[0])/16;
return Convert.ToInt16(j);
}
#region 中值滤波
//private static int DataWindowCount=109;
public static short[] GetMidFilterData(short[] Data int FirstDataWindowCount int SecondDataWindowCount)
{
short[] Result = new short[Data.Length];
Result = GetMedianFilterData(Data FirstDataWindowCount);
Result = GetMedianFilter
- 上一篇:C# .NET网上选课系统
- 下一篇:串口调试助手C#源代码
评论
共有 条评论