[英]Converting a Bitmap image to a matrix
In C#, I need to convert an image that I have already converted to Bitmap in to a matrix of the size of the image's width and height that consists of the uint8 of the Bitmap data. 在C#中,我需要将已经转换为Bitmap的图像转换为图像宽度和高度的矩阵,该矩阵由位图数据的uint8组成。 In another word placing the Bitmap data inside of a matrix and converting them to uint8, so I can do the calculations that I am intended to do on the matrix rows and column.
换句话说,将位图数据放在矩阵中并将它们转换为uint8,这样我就可以对矩阵行和列进行计算。
Try something like this: 尝试这样的事情:
public Color[][] GetBitMapColorMatrix(string bitmapFilePath)
{
bitmapFilePath = @"C:\9673780.jpg";
Bitmap b1 = new Bitmap(bitmapFilePath);
int hight = b1.Height;
int width = b1.Width;
Color[][] colorMatrix = new Color[width][];
for (int i = 0; i < width; i++)
{
colorMatrix[i] = new Color[hight];
for (int j = 0; j < hight; j++)
{
colorMatrix[i][j] = b1.GetPixel(i, j);
}
}
return colorMatrix;
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.