displaying 16 bit image with stop byte

asked 2014-02-27 10:07:16 -0500

Guyygarty gravatar image

Hi, I am trying to display a 16 bit image obtained from a scientific CMOS camera. The camera returns an unsigned char array containing height x (2 x width+1) elements. namely, each pixel is encoded as two chars and there is an additional 0-valued char at the end of each row. I have figured out how to load the image into a Mat correctly, by specifying the step as 2*width+1. imwrite also works properly, saving a reasonable image.

My problem is with imshow. The image generated regards the stop byte as the first byte of the next row. Subsequently the displayed image consists of alternating "dark" and "light" rows, as the pixels switch from big endian to little endian and back. Every two rows, there is a 1 pixel shift to the right.

Is there any way of telling imshow to disregard this byte? guy

edit retag flag offensive close merge delete

Comments

Can't you filter it out as you read in the data and load the mat?

GrumbleLion gravatar imageGrumbleLion ( 2014-03-08 19:17:45 -0500 )edit