【问题标题】:How to convert Image type to Image<Bgr, Byte>?如何将 Image 类型转换为 Image<Bgr, Byte>?
【发布时间】:2012-08-28 04:29:58
【问题描述】:

知道如何将Image 类型转换为Image&lt;Bgr, Byte&gt; 类型吗?

我从PictureBoxControl 获取图像,我需要将其转换为Image&lt;Bgr, Byte&gt; 类型。

Image pictureBoxImage = pictureBox.Image;
Image<Bgr, Byte> image = // ...

【问题讨论】:

标签: c# .net opencv emgucv


【解决方案1】:

根据documentation

从位图创建图像

也可以从 .Net 创建一个Image&lt;TColor, TDepth&gt; Bitmap对象

所以,你应该可以做到:

var image = new Image<Bgr, Byte>(new Bitmap(pictureBox.Image));

【讨论】:

    【解决方案2】:

    你也可以这样做:

    Image<Bgr, Byte> IMG = new Image<Bgr, byte>((Bitmap)pictureBox1.Image);
    

    var IMG = new Image<Bgr, byte>((Bitmap)pictureBox1.Image);
    

    【讨论】:

    • var--在接受的答案中使用--是复杂数据类型的首选声明。
    【解决方案3】:

    对于 Emgu.CV 4.5,我必须添加 Emgu.CV.Bitmap 包并使用 bitmap.ToImage&lt;Bgr, byte&gt;()

    using (Bitmap bitmap = new Bitmap(pictureBox.Image))
    {
        Image<Bgr, byte> image = bitmap.ToImage<Bgr, byte>();
    }
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2017-12-12
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2020-02-25
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多