Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/apache-kafka/3.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# 为什么ImageStatistics.Gray为空?_C#_Null_Histogram_Aforge - Fatal编程技术网

C# 为什么ImageStatistics.Gray为空?

C# 为什么ImageStatistics.Gray为空?,c#,null,histogram,aforge,C#,Null,Histogram,Aforge,我正在使用一个org.net,我想在一个文本框中显示标准偏差的值。以下代码不起作用: AForge.Imaging.ImageStatistics stat = new AForge.Imaging.ImageStatistics(btm_1); AForge.Math.Histogram gray = stat.Gray; this.textB_1.Text = gray.StdDev.ToString(); 它失败,出现以下错误: 对象引用未设置为对象的实例 gray和stat.gray都

我正在使用一个org.net,我想在一个文本框中显示标准偏差的值。以下代码不起作用:

AForge.Imaging.ImageStatistics stat = new AForge.Imaging.ImageStatistics(btm_1);
AForge.Math.Histogram gray = stat.Gray;
this.textB_1.Text = gray.StdDev.ToString();
它失败,出现以下错误:

对象引用未设置为对象的实例


gray
stat.gray
都为空。

您有灰度图像吗?

gray属性的属性显示:

注意:该属性仅对灰度图像有效(请参见属性)


我猜您的图像不是灰度图像,
Gray
属性返回null。它最好抛出一个
invalidoOperationException
,因为它可以让您深入了解错误的原因,并且会很快失败。

这不是标准的划分。这是标准差。我肯定有灰度图像。我用阈值对它进行二值化,我还使用了一个RGE的Canny边缘检测器。它工作得很好,这就是为什么我惊讶于我有直方图的问题。