我是Emgu Cv的新手,我想知道是否有人可以让我知道我如何将Emgu.Cv. image更改为System.Image?如果需要进一步解释,请告诉我,我会做的。我使用的语言是c#
您可以使用ToImage()
方法获得System.Drawing.Bitmap
(这是System.Drawing.Image
的派生类),因此类似于以下内容
// create an Emgu image of 400x200 filled with Blue color
Image<Bgr, Byte> img = new Image<Bgr, byte>(400, 200, new Bgr(255, 0, 0));
// copy to a .NET image
System.Drawing.Image pMyImage = img.ToBitmap();
你是这个意思吗?
接受的答案是过时的,因为新版本的Emgu CV已经发布,其中Image<Bgr, byte>
对象没有ToBitmap()
方法。要将Image<Bgr, byte>
对象的实例转换为Bitmap
对象,则需要从图像中获取字节数组,然后使用字节数组构建内存流对象,然后将内存流对象传递给位图构造器重载,该构造器接受内存流对象参数。
//load an image into an Image<Byte, byte> object
var image = new Image<Bgr, byte>("file.png");
//get the jpeg representation of the image
var arr = image.ToJpegData(95);
//get a memory stream out of the byte array
var stream = new MemoryStream(arr) ;
//pass the memory stream to the bitmap ctor
var bitmap = new Bitmap(stream) ;
//TO DO with bitmap