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

问题描述 投票:1回答:3

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

  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必须相同)

example

flex image getpixel
3个回答
2
投票

getPixel应该返回像素的十六进制值,然后你可以做类似的事情

//得到红色值

bmd.getPixel(i,j) >> 16

1
投票
//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];

            }
        }

0
投票
Bitmap bmp = new Bitmap(pictureBox1.Image);
bmp.getPixel(i,j).R
© www.soinside.com 2019 - 2024. All rights reserved.