开发者

Bitmap to image conversion

more information to last post(being more specific)

hi, I want to take advantages from emgucv and at the same time agorge.net.

Problem I am facing is type conversion

//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");

How can i interchange these two types.

Bitmap->image (to base class)

e.g.,

Bitmap grayImage = filter.Ap开发者_开发知识库ply(image1.Bitmap);

now want to use
ImageViewer.Show(grayImage, "test"); //error

regards, shahzad


Actually, a System.Image.Bitmap class is an Image class. See the documentation for more info. System.Drawing.Image is an abstract base class.

As far as using AForge goes, you can use the grayscale class to convert to grayscale:

// create grayscale filter (BT709)
Grayscale filter = new Grayscale( 0.2125, 0.7154, 0.0721 );
// apply the filter
Bitmap grayImage = filter.Apply( image );

AForge's Grayscale class takes a Bitmap instance in the Apply call, so you can simply use the Bitmap.FromFile method.

Edit: some more info on using AForge to convert to gray scale


Emgu CV's Image class has a ToBitmap() method.

So it's as trivial as:

image1.ToBitmap();
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜