6
我有一個MxNx3矩陣,我想用MWArray
將它轉換爲matlab。
這是我的代碼,但是沒有CTOR。
有什麼辦法可以做到嗎?將C#數組轉換爲MWarray Matlab
RGBImage image = _currentImage as RGBImage;
int height = image.Height;
int width = image.Width;
//transform the 1D array of byte into MxNx3 matrix
byte[, ,] rgbByteImage = new byte[3, height, width];
if (image[0].Bpp > 16)
{
for (int i = 0; i < height; i++)
{
for (int j = 0, k = 0; k < width; j = j + 3, k++)
{
rgbByteImage[0, i, k] = image[0].Data[i * width + j];
rgbByteImage[1, i, k] = image[0].Data[i * width + j + 1];
rgbByteImage[2, i, k] = image[0].Data[i * width + j + 2 ];
}
}
}
MWNumericArray tempArr = new MWNumericArray(rgbByteImage);