在C#中使用emguCV转换为灰度 [英] Conversion to grayscale using emguCV in C#

查看:370
本文介绍了在C#中使用emguCV转换为灰度的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是EmguCV的新手。我想将RGB图像转换为灰度。对于转换,我使用了代码

I am new to EmguCV. I want to convert an rgb image into gray scale. For the conversion I have used the code

Image<Gray,byte> grayImage = ColordImage.Convert<Gray, byte>();

现在,当我在C#中编译此代码时,它没有错误,但是当我运行它之后,几秒钟后,这行代码使我感到异常,因为OpenCV不支持这种类型的转换。现在任何人都可以帮助我解决这个问题。

Now when i compile this code in C# it gives no error,but when i run it then after a few seconds it gives me the exception at this line of code that this type of conversion is not supported by OpenCV. Now can any one help me solve this problem.

关于
Amal

Regards Amal

推荐答案

这可能取决于ColordImage的颜色类型。

It may depend on the type of colour that ColordImage is.

例如,此方法有效:

Capture cap = new Capture(1);
Image <Bgr,Byte> ColordImage = cap.QueryFrame();
Image <Gray,Byte> grayImage = ColordImage.Convert<Gray, Byte>();
imageBox1.Image = grayImage;

如果您可以提供更多的代码,则可能会更加明显。

If you could supply more of your code, it might become more obvious what's going on.

这篇关于在C#中使用emguCV转换为灰度的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆