我有一个12位灰度相机,我想使用EMGU来处理图像。
我的问题是我想在"UInt16“TDepth而不是通常的"Byte”处理图像。
因此,最初我创建一个空的2D图像:
Image<Gray, UInt16> OnImage = new Image<Gray, UInt16>(960, 1280); 然后创建一个for循环,将图像从一维矢量表单转换为2D图像:
for (int i=1; i< 960; i++)
{
for (int j = 1; j < 1280; j++)
{
OnImage[i, j] = MyImageVector[Counter];
Counter++;
}
} 其中:
int[] MyImageVector = new int[1228800];问题就在眼前:
OnImage[i, j] = MyImageVector[Counter];在其中,我得到以下错误消息:
不能隐式地将类型"int“转换为"EMGU.CV.Structure.Gray”
为什么会发生这种事?
你知道我能把Int值存储到Emgu Image对象吗?
任何替代的解决办法也将是有益的。
谢谢
发布于 2015-11-11 11:43:59
我找到了一种将一维向量传递到2D EMGU.Image的替代解决方案:
Image<Gray, Single> _myImage= new Image<Gray, Single>(Width, Height);
Buffer.BlockCopy(MyVector, 0, _myImage.Data, 0, MyVector.Length * sizeof(Single));这比循环2要快得多.
https://stackoverflow.com/questions/33608687
复制相似问题