Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

From the head:

#include <opencv2/opencv.hpp>

using namespace cv;

// Your CV_16U3 Mat
Mat image16u3 = //$your data$;

// Convert it to CV_8U3 Mat
Mat image8u3;
image16u3.convertTo(image8U3, CV_8U3);

// Convert color to grayscale
Mat image8u1;
cvtColor(image8u3, image8u1, COLOR_RGB2GRAY);

From the head:

#include <opencv2/opencv.hpp>

using namespace cv;

// Your CV_16U3 Mat
Mat image16u3 = //$your data$;

// Convert it to CV_8U3 Mat
Mat image8u3;
image16u3.convertTo(image8U3, CV_8U3);
CV_8UC3); // CV_8U should work as well

// Convert color to grayscale
Mat image8u1;
cvtColor(image8u3, image8u1, COLOR_RGB2GRAY);

Edit: Code corrected (see below)