Is there a way to convert from CV_8UC3 Mat to CV_32FC3 Mat without directly accessing the raw buffer? I tried Mat::convertTo(newImage, CV_32FC3, 1.0);
but the colors end up wrong. Thanks.
The convention is, that for the type CV_8UC3 the pixels values range from 0 to 255, and for type CV_32FC3 from 0.0 to 1.0. Thus you need to use a scaling factor of 1/255.0 instead of 1.0:
Mat::convertTo(newImage, CV_32FC3, 1/255.0);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With