为什么ImageStatistics.Gray为null?

我正在使用AForge.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
财产的官方文件说:   注意:该属性仅对灰度图像有效(请参阅IsGrayscale属性)。 我猜你的图像不是灰度图像,
Gray
属性返回null。它最好抛出一个
InvalidOperationException
,因为它可以提供一些有关错误原因的见解,并且它会快速失败。     

要回复问题请先登录注册