python一维高斯滤波
python一维高斯滤波B站:Halcom中国的动态-哔哩哔哩 (bilibili.com)
private static void SmoothFunct1dGauss(List<double> Function, double sigma, out List<double> SmoothedFunction)
{
SmoothedFunction = new List<double>();
//构造高斯核函数
double mu = 0; // 均值
//double sigma = 5.3;// sigma
int LengthG = Convert.ToInt32(3 * sigma);
if (LengthG < 1)
{
LengthG = 1;
}
List<double> GaussianKernel = new List<double>();
for (int i = -LengthG; i <= LengthG; i++)
{
double xout = 0;
GaussianCore(i, mu, sigma, out xout);
GaussianKernel.Add(xout);
}
// 对一维数据序列进行卷积滤波
//List<double> SmoothedFunction = new List<double>();
for (int i = 0; i < Function.Count(); i++)
{
if (i <= 2)
{
SmoothedFunction.Add(Function);
}
else
{
double xout = 0;
for (int j = 0; j < GaussianKernel.Count(); j++)
{
if (i + j - LengthG < 0)
{
xout = xout + GaussianKernel * Function;
}
else if (i + j - LengthG > Function.Count() - 1)
{
xout = xout + GaussianKernel * Function;
}
else
{
xout = xout + GaussianKernel * Function;
}
}
SmoothedFunction.Add(xout);
}
}
}
>错误
页:
[1]