I have a cv::Mat image of type CV_16UC1 and I need it in CV_8UC1, so I can run cv::integral on it. I am not worried about overflow during the conversion - essentially I just want to bulk convert the image from unsigned short to unsigned char.
I asked elsewhere and someone suggested cvtColor, but I don't know what conversion code to use.
CV_8UC1 is an unsigned char .
CV_8UC3 - 3 channel array with 8 bit unsigned integers. CV_8UC4 - 4 channel array with 8 bit unsigned integers. CV_8UC(n) - n channel array with 8 bit unsigned integers (n can be from 1 to 512) )
How about using Mat::convertTo? Documentation
A quick example: (not sure if you need scalefactor though, since I haven't tried)
Your16Image.convertTo(outputImage, CV_8UC1, scalefactor)
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