1

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

n00ki3
  • 14,529
  • 18
  • 56
  • 65

3 Answers3

2

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
Chris Gutierrez
  • 4,750
  • 19
  • 18
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];

            }
        }
AMagic
  • 2,690
  • 3
  • 21
  • 33
  • Thanks for posting an answer! While a code snippet could answer the question it's still great to add some addition information around, like explain, etc .. – j0k Sep 23 '12 at 10:03
0
Bitmap bmp = new Bitmap(pictureBox1.Image);
bmp.getPixel(i,j).R
Zoe
  • 27,060
  • 21
  • 118
  • 148
  • 1
    Please explain your answer and use code formatting for code. 4 spaces at the start of each line works for blocks of code. – tshimkus Feb 17 '19 at 02:55