我有一个灰度图像,我想扫描图像中的像素,这就是我得到的:
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必须相同)
答案 0 :(得分:2)
getPixel应返回像素的十六进制值,然后您可以执行类似
的操作//获取红色值
bmd.getPixel(i,j) >> 16
答案 1 :(得分: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];
}
}
答案 2 :(得分:0)
Bitmap bmp = new Bitmap(pictureBox1.Image);
bmp.getPixel(i,j).R