用于使用c#的LOOP Emgu GPU [英] FOR LOOP Emgu GPU using c #

查看:81
本文介绍了用于使用c#的LOOP Emgu GPU的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有人可以告诉我如何使用GPU EMGU进行for循环c#



Can someone please tell me how to make a for loop using GPU EMGU c #

unsafe
           {
               byte* p = (byte*)(void*)Scan0;
               byte* pSrc = (byte*)(void*)SrcScan0;

               int nOffset = stride - b.Width * 3;
               int nWidth = b.Width - 2;
               int nHeight = b.Height - 2;

               int nPixel;

               for (int y = 0; y < nHeight; ++y)
               {
                   for (int x = 0; x < nWidth; ++x)
                   {

                       nPixel = ((((pSrc[2] * m.TopLeft) + (pSrc[5] * m.TopMid) + (pSrc[8] * m.TopRight) +
                           (pSrc[2 + stride] * m.MidLeft) + (pSrc[5 + stride] * m.Pixel) + (pSrc[8 + stride] * m.MidRight) +
                           (pSrc[2 + stride2] * m.BottomLeft) + (pSrc[5 + stride2] * m.BottomMid) + (pSrc[8 + stride2] * m.BottomRight)) / m.Factor) + m.Offset);

                       if (nPixel < 33) nPixel = 0;     //if (nPixel < 0) nPixel = 0;
                       if (nPixel > 34) nPixel = 255;  //if (nPixel > 255) nPixel = 255;

                       p[5 + stride] = (byte)nPixel;

                       nPixel = ((((pSrc[1] * m.TopLeft) + (pSrc[4] * m.TopMid) + (pSrc[7] * m.TopRight) +
                           (pSrc[1 + stride] * m.MidLeft) + (pSrc[4 + stride] * m.Pixel) + (pSrc[7 + stride] * m.MidRight) +
                           (pSrc[1 + stride2] * m.BottomLeft) + (pSrc[4 + stride2] * m.BottomMid) + (pSrc[7 + stride2] * m.BottomRight)) / m.Factor) + m.Offset);


                       if (nPixel < 33) nPixel = 0;
                       if (nPixel > 34) nPixel = 255;

                       p[4 + stride] = (byte)nPixel;

                       nPixel = ((((pSrc[0] * m.TopLeft) + (pSrc[3] * m.TopMid) + (pSrc[6] * m.TopRight) +
                           (pSrc[0 + stride] * m.MidLeft) + (pSrc[3 + stride] * m.Pixel) + (pSrc[6 + stride] * m.MidRight) +
                           (pSrc[0 + stride2] * m.BottomLeft) + (pSrc[3 + stride2] * m.BottomMid) + (pSrc[6 + stride2] * m.BottomRight)) / m.Factor) + m.Offset);

                       if (nPixel < 33) nPixel = 0;
                       if (nPixel > 34) nPixel = 255;

                       p[3 + stride] = (byte)nPixel;

                       p += 3;
                       pSrc += 3;



                   }
                   p += nOffset;
                   pSrc += nOffset;

               }




           }

推荐答案

这篇关于用于使用c#的LOOP Emgu GPU的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆