How to convert Image<Gray, Byte> to Image<Gray, float>?

c#, emgucv

Solution

To quote from 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>();

So, in your case, you could use

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

Problem

I'm trying to substract 1 image from another, somewhat like this: ``` Image<Gray, float> result, secondImage; Image<Gray, byte> firstImage; result = firstImage - secondImage; ``` But it gives an error ``` 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>' ``` Maybe i need to convert firstImage into `Image<Gray, float>` type. But I don't know how to do it.

Original source