【问题标题】:Get Black and White 2 BIT image using Emgu CV使用 Emgu CV 获取黑白 2 位图像
【发布时间】:2017-07-06 21:48:47
【问题描述】:

您好,我需要将图像转换为黑白和 2 位深度。

我尝试了以下操作,它生成了一个 8 位的图像。没有看到任何生成 2 位图像的选项。

Emgu.CV.Image<Gray, Single> image = new Emgu.CV.Image<Gray, Single>("test.jpg");

有人可以建议吗?

【问题讨论】:

    标签: c# emgucv


    【解决方案1】:

    在 emgucv 中你有以下图像深度

    Byte、SByte、Single(浮点)、Double、UInt16、Int16、Int32(int) (来自emgucv

    您没有 2 位深度。 但是你可以制作一个看起来像这样的 2 位图像的图像:

    var theImage = new Image<Gray, byte>(@"d:\temp\lena.jpg");
            for (int i = theImage.Rows - 1; i >= 0; i--)
            {
                for (int j = theImage.Cols - 1; j >= 0; j--)
                {
                    if(theImage.Data[i,j,0]>byte.MaxValue/2)
                    {
                            theImage.Data[i, j, 0] = byte.MaxValue;
                    }
                    else
                    {
                        theImage.Data[i, j, 0] = 0;
                    }
    
                }
            }
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2017-12-24
      • 1970-01-01
      • 1970-01-01
      • 2012-11-18
      • 1970-01-01
      • 1970-01-01
      • 2011-07-03
      • 2015-03-08
      相关资源
      最近更新 更多