如何将图像<灰色,字节>转换为图像<灰色,浮点>
本文关键字:灰色 图像 浮点 转换 字节 | 更新日期: 2023-09-27 18:35:14
我试图从另一张图像中减去 1 张图像,有点像这样:
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>'
也许我需要将第一图像转换为Image<Gray, float>
类型。但我不知道该怎么做。
引用文档:
颜色和深度转换
在不同的颜色和深度之间转换图像很简单。例如,如果您有图像img1并且想要将其转换为Single的灰度图像,则您需要做的就是
Image<Gray, Single> img2 = img1.Convert<Gray, Single>();
因此,在您的情况下,您可以使用
result = firstImage.Convert<Gray, float>() - secondImage;