Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

no idea, if it really fits your situation, but an easy way to "splice" 2 8bit images into a 16bit one would be:

// our input:
Mat A(h,w,CV_8U);
Mat B(h,w,CV_8U);

now assuming, we want A as the "low nibble", and B as the "high nibble":

A.convertTo(A, CV_16U);
B.convertTo(B, CV_16U, 255); // shift 8 bits to the right

Mat C = A + B;

no idea, if it really fits your situation, but an easy way to "splice" 2 8bit images into a 16bit one would be:

// our input:
Mat A(h,w,CV_8U);
Mat B(h,w,CV_8U);

now assuming, we want A as the "low nibble", and B as the "high nibble":

A.convertTo(A, CV_16U);
B.convertTo(B, CV_16U, 255); // shift 8 bits to the right
left

Mat C = A + B;

no idea, if it really fits your situation, but an easy way to "splice" 2 8bit images into a 16bit one would be:

// our input:
Mat A(h,w,CV_8U);
Mat B(h,w,CV_8U);

now assuming, we want A as the "low nibble", and B as the "high nibble":

A.convertTo(A, CV_16U);
B.convertTo(B, CV_16U, 255); 256); // shift 8 bits to the left

Mat C = A + B;

no idea, if it really fits your situation, but an easy way to "splice" 2 8bit images into a 16bit one would be:

// our input:
Mat A(h,w,CV_8U);
Mat B(h,w,CV_8U);

now assuming, we want A as the "low nibble", and B as the "high nibble":

// if you think in bits, below is:
// 00000000AAAAAAAA
A.convertTo(A, CV_16U);

// BBBBBBBB00000000
B.convertTo(B, CV_16U, 256); // shift 8 bits to the left

// BBBBBBBBAAAAAAAA
Mat C = A + B;