我正试图将一些Python代码转换成C#,但代码实现上的差异使我无法实现我的目标。你知道吗
我尝试创建不同的数组和函数来使用另一个数组规范化一个C#float数组。你知道吗
Python代码:
mean_vec = np.array([102.9801, 115.9465, 122.7717])
for i in range(image.shape[0]):
image[i, :, :] = image[i, :, :] - mean_vec[i]
我在C#中尝试的代码:
Image<Bgr, byte> image = new Image<Bgr, byte>(newBitmap);
Mat newMat = image.Mat;
float[] array = new float[(int)newMat.Total];
newMat.CopyTo(array);
float[] mean_vector = new float[] { 102.9801f, 115.9465f, 122.7717f };
for(int i=0; i<bitmapWidth; i++)
{
for(int j=0; j<3; j++)
array[i] = array[i] - mean_vector[j];
}
我得到以下错误
"System.IndexOutOfRangeException: 'Index was outside the bounds of the array.'"
相关问题 更多 >
编程相关推荐