Converting 16UC1 to 8UC3 without the loss of the data
I'm trying to convert a 16UC1 mat to an 8UC3 mat, somehow without truncating the data. Do you have a preferred method? The code I'm trying splits the one 16-bit value into two 8-bit values, which I use for the blue and green channels.
UINT16 a = frame_content.at<UINT16>(j, i);
BYTE hi = (a >> 8) & 0xff;
BYTE low = (a >> 0) & 0xff;
byte_frame_content.at<Vec3b>(j, i)[0] = hi; // blue
byte_frame_content.at<Vec3b>(j, i)[1] = low; // green
byte_frame_content.at<Vec3b>(j, i)[2] = 0; // red