Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

Accessing pixel intensity values 16 unsigned char

I have the following reference: Link

to access the pixel intensity values of an image. This image is being converted from ROS to OpenCV and can be converted to two different formats: 32 bit float and 16 bit unsigned char. This is a depth image coming out of zed camera and hence uses single channel. I am working with C++ and the code is running as a ROS node. The above link has the following line:

Scalar intensity = img.at<uchar>(y, x);

I have two questions: 1) For 32FC1 format, I tried replacing uchar with float and it worked. Is this the right way to do it or is there a better option? 2) I am not able to find the uchar counterpart for 16 bit unsigned char (16UC1). I tried using uchar itself, but it is giving me mostly zeros and I am pretty convinced that it is not right. Any help would be appreciated.