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

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

例如

有帮助吗?

解决方案

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

//获得红色值

bmd.getPixel(i,j) >> 16

其他提示

//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];

            }
        }
Bitmap bmp = new Bitmap(pictureBox1.Image);
bmp.getPixel(i,j).R
许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top