getPixel-method - 如何获取 RGB 的 R 值?

发布于 2024-08-11 16:46:06 字数 403 浏览 1 评论 0原文

我有一个灰度图像,我想扫描图像中的像素,这就是我得到的:

  var i:int;
  var j:int;
  for (i = 0; i < img.contentWidth ; i++)
   {
     for(j = 0; j < img.contentHeight; j++){
        pixeldaten.addItem({x:i,y:j,pixel:bmd.getPixel(i,j)});

     }
   }

但该表看起来不像 RGB 值。 (R、B 和 G 必须相同)

示例

i have a greyscale image and i want to scan the pixels out of the Image and this is what i get :

  var i:int;
  var j:int;
  for (i = 0; i < img.contentWidth ; i++)
   {
     for(j = 0; j < img.contentHeight; j++){
        pixeldaten.addItem({x:i,y:j,pixel:bmd.getPixel(i,j)});

     }
   }

but the table doesn't look like RGB Values . (R , B , and G must be the same)

: example

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

很快妥协 2024-08-18 16:46:06

getPixel 应该返回像素的十六进制值,然后您可以执行类似

// 获取红色值的操作

bmd.getPixel(i,j) >> 16

getPixel should return the hex value value of the pixel, you could then do something like

// get the red value

bmd.getPixel(i,j) >> 16
情绪 2024-08-18 16:46:06
//for Image processing
        Bitmap myBitmap = new Bitmap(CurrentBitmap);
        int imgH = myBitmap.Height;
        int imgW = myBitmap.Width;
        ARed = new double[imgH, imgW];
        AGreen = new double[imgH, imgW];
        ABlue = new double[imgH, imgW];
        doubles = new double[imgH, imgW];

        var max = new double[imgH, imgW];
        var min = new double[0, 0];

        //seperating each RGB components
        for (int x = 0; x < imgH; x++)
        {
            for (int y = 0; y < imgW; y++)
            {
                Color color = myBitmap.GetPixel(x, y);
                // things we do with pixelColor
                //ARed[x][y] = myBitmap.GetPixel >> 16;
                ARed[x, y] = color.R;
                ABlue[x, y] = color.B;
                AGreen[x, y] = color.G;
                max[x, y] = ARed[x, y];

            }
        }
//for Image processing
        Bitmap myBitmap = new Bitmap(CurrentBitmap);
        int imgH = myBitmap.Height;
        int imgW = myBitmap.Width;
        ARed = new double[imgH, imgW];
        AGreen = new double[imgH, imgW];
        ABlue = new double[imgH, imgW];
        doubles = new double[imgH, imgW];

        var max = new double[imgH, imgW];
        var min = new double[0, 0];

        //seperating each RGB components
        for (int x = 0; x < imgH; x++)
        {
            for (int y = 0; y < imgW; y++)
            {
                Color color = myBitmap.GetPixel(x, y);
                // things we do with pixelColor
                //ARed[x][y] = myBitmap.GetPixel >> 16;
                ARed[x, y] = color.R;
                ABlue[x, y] = color.B;
                AGreen[x, y] = color.G;
                max[x, y] = ARed[x, y];

            }
        }
忘年祭陌 2024-08-18 16:46:06
Bitmap bmp = new Bitmap(pictureBox1.Image);
bmp.getPixel(i,j).R
Bitmap bmp = new Bitmap(pictureBox1.Image);
bmp.getPixel(i,j).R
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文