public Matrix ToMatrix(Bitmap bm)
{
int height = bm.Height;
int width = bm.Width;
Matrix M = new Matrix(height, width);
Color pixelColor;
//iterate through the Bitmap, getting the colors from each pixel, convert the colors to RGB alpha value and store in a Matrix
for (int i = 0; i < width; i++)
{
for (int j = 0; j < height; j++)
{
pixelColor = bm.GetPixel(i, j); //get pixel color from Bitmap
M.set(i, j, pixelColor.ToArgb()); //convert to alpha RGB and store in the Matrix, M
}
}
return M;
}