【发布时间】:2015-02-19 01:29:42
【问题描述】:
我有一个循环在 C# 中太慢了。我想知道是否有更快的方法来处理这些数组。我目前正在使用 .NET 2.0。我不反对升级这个项目。这是涉及灰度级的理论图像处理概念的一部分。
- 像素数 (PixCnt = 21144402)
- g_len = 4625
- list1d - 具有上述像素数上限的图像的 1 维数组。
- pg - 灰度强度保持器。
此函数创建这些值的索引。因此 pgidx。
int[] pgidx = new int[PixCnt];
sw = new Stopwatch();
sw.Start();
for (i = 0; i < PixCnt; i++)
{
j = 0;
pgidx[i] = 0;
while (list_1d[i] != pg[j] && j < g_len) j++;
if (list_id[i] == pg[j])
pgidx[i] = j
}
sw.stop();
Debug.WriteLine("PixCnt Loop took" + sw.ElapsedMilliseconds + " ms");
【问题讨论】:
-
多长时间太慢了?
-
你的变量命名很难理解。
标签: c# arrays performance image-processing optimization