Hello Mat

 找回密码
 立即注册
查看: 940|回复: 1

python一维高斯滤波

[复制链接]

1294

主题

1520

帖子

110

金钱

管理员

Rank: 9Rank: 9Rank: 9

积分
22633
发表于 2023-12-11 09:43:49 来自手机 | 显示全部楼层 |阅读模式
python一维高斯滤波
B站:Halcom中国的动态-哔哩哔哩 (bilibili.com)

  1.         private static void SmoothFunct1dGauss(List<double> Function, double sigma, out List<double> SmoothedFunction)
  2.         {
  3.             SmoothedFunction = new List<double>();
  4.             //  构造高斯核函数
  5.             double mu = 0;       // 均值
  6.             //double sigma = 5.3;  // sigma
  7.             int LengthG = Convert.ToInt32(3 * sigma);
  8.             if (LengthG < 1)
  9.             {
  10.                 LengthG = 1;
  11.             }
  12.             List<double> GaussianKernel = new List<double>();
  13.             for (int i = -LengthG; i <= LengthG; i++)
  14.             {
  15.                 double xout = 0;
  16.                 GaussianCore(i, mu, sigma, out xout);
  17.                 GaussianKernel.Add(xout);
  18.             }
  19.             // 对一维数据序列进行卷积滤波
  20.             //List<double> SmoothedFunction = new List<double>();
  21.             for (int i = 0; i < Function.Count(); i++)
  22.             {
  23.                 if (i <= 2)
  24.                 {
  25.                     SmoothedFunction.Add(Function[i]);
  26.                 }
  27.                 else
  28.                 {
  29.                     double xout = 0;
  30.                     for (int j = 0; j < GaussianKernel.Count(); j++)
  31.                     {
  32.                         if (i + j - LengthG < 0)
  33.                         {
  34.                             xout = xout + GaussianKernel[j] * Function[i];
  35.                         }
  36.                         else if (i + j - LengthG > Function.Count() - 1)
  37.                         {
  38.                             xout = xout + GaussianKernel[j] * Function[i];
  39.                         }
  40.                         else
  41.                         {
  42.                             xout = xout + GaussianKernel[j] * Function[i + j - LengthG];
  43.                         }
  44.                     }
  45.                     SmoothedFunction.Add(xout);
  46.                 }
  47.             }
  48.         }
复制代码




回复

使用道具 举报

1294

主题

1520

帖子

110

金钱

管理员

Rank: 9Rank: 9Rank: 9

积分
22633
 楼主| 发表于 2023-12-11 14:11:14 来自手机 | 显示全部楼层
>错误
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

Python|Opencv|MATLAB|Halcom.cn ( 蜀ICP备16027072号 )

GMT+8, 2024-4-28 12:32 , Processed in 0.209040 second(s), 21 queries .

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

快速回复 返回顶部 返回列表