http://stackoverflow.com/questions/18766004/how-to-convert-from-system-drawing-bitmap-to-grayscale-then-to-array-of-doubles
----------------------------------------------------------------------
public static byte[,] ToGrayscale(Bitmap bitmap)
{
var result = new byte[bitmap.Width, bitmap.Height];
for (int x = 0; x < bitmap.Width; x++)
for (int y = 0; y < bitmap.Height; y++)
{
var grayColor = ToGrayscaleColor(bitmap.GetPixel(x, y));
result[x, y] = (byte)grayColor;
}
return result;
}
public static byte ToGrayscaleColor(Color color)
{
var level = (byte)((color.R + color.G + color.B) / 3);
return level;
}
댓글 없음:
댓글 쓰기