Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/263.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
从c++;opencv到c#emgu cv? 我是C语言上的新手,我想把这个代码从C++翻译成C语言。程序包括确定图像是否为白色,这就是为什么我尝试获取所有像素的值,并将其与0进行比较 int image_blanche(char * str, double prctage){ Mat img=imread(str); int compt=0; for(int i=0;i<img.rows;i++){ for(int j=0;j<img.cols;j++){ if (img.at<uchar>(i,j)==0){ compt=compt+1; } } } if (compt< img.rows*img.cols*prctage) { return 1; } else if (compt> img.rows*img.cols*prctage){ return 0; } } int image\u blanche(字符*str,双字符){ Mat img=imread(str); int compt=0; 对于(int i=0;i_C#_C++_Opencv_Emgucv - Fatal编程技术网

从c++;opencv到c#emgu cv? 我是C语言上的新手,我想把这个代码从C++翻译成C语言。程序包括确定图像是否为白色,这就是为什么我尝试获取所有像素的值,并将其与0进行比较 int image_blanche(char * str, double prctage){ Mat img=imread(str); int compt=0; for(int i=0;i<img.rows;i++){ for(int j=0;j<img.cols;j++){ if (img.at<uchar>(i,j)==0){ compt=compt+1; } } } if (compt< img.rows*img.cols*prctage) { return 1; } else if (compt> img.rows*img.cols*prctage){ return 0; } } int image\u blanche(字符*str,双字符){ Mat img=imread(str); int compt=0; 对于(int i=0;i

从c++;opencv到c#emgu cv? 我是C语言上的新手,我想把这个代码从C++翻译成C语言。程序包括确定图像是否为白色,这就是为什么我尝试获取所有像素的值,并将其与0进行比较 int image_blanche(char * str, double prctage){ Mat img=imread(str); int compt=0; for(int i=0;i<img.rows;i++){ for(int j=0;j<img.cols;j++){ if (img.at<uchar>(i,j)==0){ compt=compt+1; } } } if (compt< img.rows*img.cols*prctage) { return 1; } else if (compt> img.rows*img.cols*prctage){ return 0; } } int image\u blanche(字符*str,双字符){ Mat img=imread(str); int compt=0; 对于(int i=0;i,c#,c++,opencv,emgucv,C#,C++,Opencv,Emgucv,您是否尝试将图像作为位图打开 Bitmap img = new Bitmap(file path); 那你就有办法了 Color c = img.GetPixel(x,y) 如果图像是纯白色的,那么每个像素必须等于255(对于8位灰度图像),或者[255](对于8位彩色图像)。因此,您可以循环浏览图像的行和列,并计算每个像素的值。获得总数后,将其与相同大小的白色图像中的总数进行比较,即灰度图像的宽度*高度*255,或彩色图像的宽度*高度*255*3。您还可以获得图像中的白度百分比通过将计数除

您是否尝试将图像作为位图打开

Bitmap img = new Bitmap(file path);
那你就有办法了

Color c = img.GetPixel(x,y)

如果图像是纯白色的,那么每个像素必须等于255(对于8位灰度图像),或者[255](对于8位彩色图像)。因此,您可以循环浏览图像的行和列,并计算每个像素的值。获得总数后,将其与相同大小的白色图像中的总数进行比较,即灰度图像的宽度*高度*255,或彩色图像的宽度*高度*255*3。您还可以获得图像中的白度百分比通过将计数除以白色图像的总数来测试图像。例如,test_img_total/width*height*255*3

为什么要从颜色中减去0,如果要查看图像是否为白色,是否应该将其与255进行比较?我的问题是如何获得c上像素的值?关于颜色和白色之间的对比255或黑色像素0。我怎么做
Color c = img.GetPixel(x,y)