本文介绍了如何从二进制图像中获取值1或0?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

限时删除!!

这是我的代码



That is my code

Image<Gray, Byte> image = new Image<Gray, byte>(Openfile.FileName);
pictureBox1.Image = image.ToBitmap();
image1 = image1.ThresholdBinary(new Gray(50), new Gray(255));



我打开我的图片桌面并将其转换为灰度,然后二进制。我想从二进制图像中获取值1或0,以便存储在矩阵中。我怎样才能做到这一点??我正在使用emgucv。


I open an image from my desktop and convert it to grayscale and then binary. I want to get either the values 1 or 0 from binary images in order to storage in matrix. How can I do that?? I am using emgucv.

推荐答案

image = image.ThresholdBinary(new Gray(50), new Gray(255));

 for (int v = 0; v < image.Height; v++)
 {
     for (int u = 0; u < image.Width; u++)
     {
         int a = image.Data[v, u, 0] & 1; //Get Pixel
    }
 }











OR

image = image.ThresholdBinary(new Gray(50), new Gray(1));

for (int v = 0; v < image.Height; v++)
{
    for (int u = 0; u < image.Width; u++)
    {
        int a = image.Data[v, u, 0]; //Get Pixel
    }
}





在这个例子中,我们使用图像的Data属性。 []


这篇关于如何从二进制图像中获取值1或0?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

1403页,肝出来的..

09-06 08:08