Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

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 red 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; byte_frame_content.at<vec3b>(j, i)[1] = low; byte_frame_content.at<vec3b>(j, i)[2] = 0;

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 red 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, byte_frame_content.at<Vec3b>(j, i)[0] = hi;
byte_frame_content.at<vec3b>(j, byte_frame_content.at<Vec3b>(j, i)[1] = low;
byte_frame_content.at<vec3b>(j, byte_frame_content.at<Vec3b>(j, i)[2] = 0;

0;

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 red and green channels.

UINT16 a = frame_content.at<uint16>(j, i);

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;
byte_frame_content.at<Vec3b>(j, i)[1] = low;
byte_frame_content.at<Vec3b>(j, i)[2] = 0;

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 red 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;
byte_frame_content.at<Vec3b>(j, i)[1] = low;
byte_frame_content.at<Vec3b>(j, i)[2] = 0;

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;
hi; // blue
byte_frame_content.at<Vec3b>(j, i)[1] = low;
low; // green
byte_frame_content.at<Vec3b>(j, i)[2] = 0;
0; // red