コード例 #1
0
 public static void Dilate2D(
     int[] src,
     int len1,
     int len2,
     int srcmask,
     int radius,
     Action <int, int> action)
 {
     Parallel.For(0, len1, (Action <int>)(x =>
     {
         MaxQueue maxQueue = new MaxQueue(radius * 2 + 1);
         for (int index = 0; index < radius; ++index)
         {
             maxQueue.Push(src[x * len2 + index] & srcmask);
         }
         for (int index = 0; index < len2; ++index)
         {
             if (index > radius)
             {
                 maxQueue.Pop();
             }
             if (index < len2 - radius)
             {
                 maxQueue.Push(src[x * len2 + index + radius] & srcmask);
             }
             if (maxQueue.get_Max() != 0)
             {
                 action(x, index);
             }
         }
     }));
     Parallel.For(0, len2, (Action <int>)(y =>
     {
         MaxQueue maxQueue = new MaxQueue(radius * 2 + 1);
         for (int index = 0; index < radius; ++index)
         {
             maxQueue.Push(src[index * len2 + y] & srcmask);
         }
         for (int index = 0; index < len1; ++index)
         {
             if (index > radius)
             {
                 maxQueue.Pop();
             }
             if (index < len1 - radius)
             {
                 maxQueue.Push(src[(index + radius) * len2 + y] & srcmask);
             }
             if (maxQueue.get_Max() != 0)
             {
                 action(index, y);
             }
         }
     }));
 }
コード例 #2
0
 public static void Dilate2D(int[] src, int len1, int len2, int srcmask, int radius, Action <int, int> action)
 {
     Parallel.For(0, len1, delegate(int x)
     {
         MaxQueue maxQueue2 = new MaxQueue(radius * 2 + 1);
         for (int k = 0; k < radius; k++)
         {
             maxQueue2.Push(src[x * len2 + k] & srcmask);
         }
         for (int l = 0; l < len2; l++)
         {
             if (l > radius)
             {
                 maxQueue2.Pop();
             }
             if (l < len2 - radius)
             {
                 maxQueue2.Push(src[x * len2 + l + radius] & srcmask);
             }
             if (maxQueue2.Max != 0)
             {
                 action(x, l);
             }
         }
     });
     Parallel.For(0, len2, delegate(int y)
     {
         MaxQueue maxQueue = new MaxQueue(radius * 2 + 1);
         for (int i = 0; i < radius; i++)
         {
             maxQueue.Push(src[i * len2 + y] & srcmask);
         }
         for (int j = 0; j < len1; j++)
         {
             if (j > radius)
             {
                 maxQueue.Pop();
             }
             if (j < len1 - radius)
             {
                 maxQueue.Push(src[(j + radius) * len2 + y] & srcmask);
             }
             if (maxQueue.Max != 0)
             {
                 action(j, y);
             }
         }
     });
 }
コード例 #3
0
 public static void Dilate2D(int[] src, int len1, int len2, int srcmask, int radius, Action <int, int> action)
 {
     Parallel.For(0, len1, (int x) => {
         MaxQueue maxQueue = new MaxQueue(radius * 2 + 1);
         for (int i = 0; i < radius; i++)
         {
             maxQueue.Push(src[x * len2 + i] & srcmask);
         }
         for (int j = 0; j < len2; j++)
         {
             if (j > radius)
             {
                 maxQueue.Pop();
             }
             if (j < len2 - radius)
             {
                 maxQueue.Push(src[x * len2 + j + radius] & srcmask);
             }
             if (maxQueue.Max != 0)
             {
                 action(x, j);
             }
         }
     });
     Parallel.For(0, len2, (int y) => {
         MaxQueue maxQueue = new MaxQueue(radius * 2 + 1);
         for (int i = 0; i < radius; i++)
         {
             maxQueue.Push(src[i * len2 + y] & srcmask);
         }
         for (int j = 0; j < len1; j++)
         {
             if (j > radius)
             {
                 maxQueue.Pop();
             }
             if (j < len1 - radius)
             {
                 maxQueue.Push(src[(j + radius) * len2 + y] & srcmask);
             }
             if (maxQueue.Max != 0)
             {
                 action(j, y);
             }
         }
     });
 }