Reputation: 965
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.
Upvotes: 6
Views: 20046
Reputation: 3988
You can use cv::convertScaleAbs which directly set your output matrix to unsigned char.
Upvotes: 1
Reputation: 577
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)
Upvotes: 10