Search code examples
opencviplimage

Accessing IplImage element of type IPL_DEPTH_16S in OpenCV


I know that for a single channel byte image you do:

((uchar *)(img->imageData + i*img->widthStep))[j]

and for a single channel float image, you do:

((float*)(img->imageData + i*img->widthStep))[j]

But how about for 16 bit signed images (IPL_DEPTH_16S), I tried:

((short*)(img->imageData + i*img->widthStep))[j]

and

((signed int*)(img->imageData + i*img->widthStep))[j]

to no avail.

Thanks,


Solution

  • Actually, the short works fine if you take widthStep/2...