标签:优化 == continue 效果 sharp value csharp mat clone
接上一篇高斯滤波,后来测试发现,与其扩充边界(费力气)处理,不如直接把之设为0(效果好):
List<Point> pointL = new List<Point>(); private void myGaussFilter123(short[,] data) { int w_Data = data.GetLength(0); int h_Data = data.GetLength(1); double[,] arr = gaussFilter(3, 1.5); for (int i = 2; i < w_Data - 1; i++) { for (int j = 2; j < h_Data - 1; j++) { bool judgeBool = false; for (int a = i - 1; a <= i + 1; a++) { for (int b = j - 1; b <= j + 1; b++) { if (Math.Abs(a - i) == 1 || Math.Abs(b - j) == 1) { if (data[a, b] == 0) { judgeBool = true; break; } } } if (judgeBool) { break; } } if (judgeBool) { if (data[i, j] > 0) { short[,] shortTmp = (short[,])data.Clone(); pointL.Add(new Point(i,j)); //data[i, j] = edgeBianTong(shortTmp, new Point(i, j), arr); } continue; } double tmpValue = 0; for (int x = 0; x < 3; x++) { for (int y = 0; y < 3; y++) { tmpValue += data[i + 1 - x, j + 1 - y] * arr[x, y];//高斯滤波矩阵是对称的 } } data[i, j] = (short)tmpValue; } } foreach (Point point in pointL) { data[point.X, point.Y] = 0; } }
标签:优化 == continue 效果 sharp value csharp mat clone
原文地址:https://www.cnblogs.com/gaara-zhang/p/9567309.html