为什么 ImageStatistics.Gray 为空?
我正在使用 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
均为 null。
I'm using AForge.net and I want to show in a textbox the value of the standard deviation. The following code is not working:
AForge.Imaging.ImageStatistics stat = new AForge.Imaging.ImageStatistics(btm_1);
AForge.Math.Histogram gray = stat.Gray;
this.textB_1.Text = gray.StdDev.ToString();
It fails with the following error:
Object reference not set to an instance of an object.
Both gray
and stat.Gray
are null.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
你有灰度图像吗?
Did you have a grayscale image?
的官方文档 >灰色
属性说:我猜测您的图像不是灰度图像,并且
Gray
属性返回 null。最好它抛出一个 InvalidOperationException ,因为它可以深入了解错误的原因,并且会快速失败。The official documentation for the
Gray
property says:I'm guessing that your image is not a grayscale image, and the
Gray
property is returning null. It would be preferable that it throw anInvalidOperationException
because it could give some insight into the cause of the error, and it would fail fast.