C# 位图到图像的转换

C# 位图到图像的转换,c#,C#,上一篇文章的更多信息更具体 嗨, 我想从emgucv和agorge.net中获益 我面临的问题是类型转换 //EMGUCV Image<Bgr, Byte> image1 = new Image<Bgr, Byte>("file.jpg"); //read the image // AFORGE.net system.drawing.Bitmap image2 = (Bitmap)Bitmap.FromFile("file.jpg"); 问候,, shahzad实

上一篇文章的更多信息更具体

嗨, 我想从emgucv和agorge.net中获益

我面临的问题是类型转换

//EMGUCV

Image<Bgr, Byte> image1 = new Image<Bgr, Byte>("file.jpg"); //read the image

// AFORGE.net
 system.drawing.Bitmap image2 = (Bitmap)Bitmap.FromFile("file.jpg");
问候,,
shahzad

实际上,System.Image.Bitmap类是一个图像类。有关详细信息,请参阅

就使用灰度而言,您可以使用转换为灰度:

// create grayscale filter (BT709)
Grayscale filter = new Grayscale( 0.2125, 0.7154, 0.0721 );
// apply the filter
Bitmap grayImage = filter.Apply( image );
Forge的Grayscale类在Apply调用中获取位图实例,因此您可以简单地使用Bitmap.FromFile方法


编辑:有关使用图像转换为灰度的更多信息,Emgu CV的图像类有一个方法

因此,这是非常琐碎的:

image1.ToBitmap();

+我只是在写这个。图像是位图的基类。是的,不完全确定这是否符合OP的帖子,但知道图像是绝对有帮助的;谢谢你的回答。但是无论如何,System.Drawing.Image和Emgu.CV.Image之间的唯一相似之处是名称。为了从图像创建实例,请查看位图的最基本构造函数:thanx,我刚刚转换为图像image2=新图像GrayImage;而且正在工作。
image1.ToBitmap();