Data Definition RGB16 Image Encoding

asked 2015-05-04 11:37:54 -0500

Diego Benavides gravatar image

I'm having difficulty publishing an RGB16 image topic. Actually, the publication is fine, it's the packaging of the image data that is not going smoothly.

I'm using openjpeg to open and decompose a JPEG2000 file. This returns me a data structure containing three 16bit arrays of data (one for each of the color channels). My confusion is how to package this information in the 8bit data matrix of a ROS message for RGB16 image types.

How should this data be arranged? Assuming R, G, and B are the arrays containing the individual color data from my openjpeg operations, I've tried the following:[] => [R0, G0, B0, R1, G1, B1 ... , R(n-1), G(n-1), B(n-1)]

and[] => [R0, R1, ... , R(n-1), B0, B1, ... , B(n-1), G0, G1, ... , G(n-1)]

Neither produce anything that looks remotely like what it should when published. Also for simplicity I've left out the fact that each entry actually accounts for the high and low byte (so R0 for example is actually two entries, R0_low, R0_high).

My encoding is set to RGB16, my step is calculated as (width * number of channels * size of bytes per channel). Have I overlooked something here?

edit retag flag offensive close merge delete