Sis*_*say 6 c# image typeconverter emgucv
有没有办法在使用C#的EmguCV上将System.Drawing.Image类型的Image转换为Emgu.CV.Image类型的Image或反之亦然?如果需要对此目的进行额外说明,我将根据您的要求进行解释.
// Converting the master image to a bitmap
Bitmap masterImage = (Bitmap) pbxMaster.Image;
// Normalizing it to grayscale
Image<Gray, Byte> normalizedMasterImage = new Image<Gray, Byte>(masterImage);
Run Code Online (Sandbox Code Playgroud)
EmguCV 版本 4.2.0.3636 [及更高版本] 使用以下代码:
using System.Drawing;
using System.Drawing.Imaging;
using Emgu.CV;
using Emgu.CV.Structure;
//inputImage type is System.Drawing.Image
Bitmap bitmapImage = new Bitmap(pictureBox1.Image);
Rectangle rectangle = new Rectangle(0, 0, bitmapImage.Width, bitmapImage.Height);//System.Drawing
BitmapData bmpData = bitmapImage.LockBits(rectangle, ImageLockMode.ReadWrite, bitmapImage.PixelFormat);//System.Drawing.Imaging
Image<Bgr, byte> outputImage = new Image<Bgr, byte>(bitmapImage.Width, bitmapImage.Height, bmpData.Stride, bmpData.Scan0);//(IntPtr)
//outputImage type is Emgu.CV.Image
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
9328 次 |
| 最近记录: |