gpt4 book ai didi

c# - 如何将 Image 转换为 Image

转载 作者:太空狗 更新时间:2023-10-30 00:43:32 25 4
gpt4 key购买 nike

我正在尝试从另一张图片中减去一张图片,有点像这样:

Image<Gray, float> result, secondImage;
Image<Gray, byte> firstImage;
result = firstImage - secondImage;

但是报错

Operator '-' cannot be applied to operands of type 'Emgu.CV.Image<Emgu.CV.Structure.Gray,byte>' and 'Emgu.CV.Image<Emgu.CV.Structure.Gray,float>'

也许我需要将 firstImage 转换为 Image<Gray, float>类型。但我不知道该怎么做。

最佳答案

引自the documentation :

Color and Depth Conversion

Converting an Image between different colors and depths are simple. For example, if you have Image img1 and you wants to convert it to a grayscale image of Single, all you need to do is

Image<Gray, Single> img2 = img1.Convert<Gray, Single>();

所以,在你的情况下,你可以使用

result = firstImage.Convert<Gray, float>() - secondImage;

关于c# - 如何将 Image<Gray, Byte> 转换为 Image<Gray, float>?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10731698/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com