Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

The img32bit.data is a generic pointer to the image data. Its content depends on the image type. Just cast it to the desired type to use it. For example if it's float (CV_32FC1):

int imW = img32bit.cols;
float *ptrF = (float*)img32bit.data;
float pix1015 = *(ptrF+10*imW+15); //get the value of pixel (10,15)

For 8 bit RGB images:

Vec3b *ptrRGB = (Vec3b*)imgRGB.data;
*(ptrRGB+15*imW+20) = Vec3b(0,255,255); //set pixel (15,20) to yellow

The img32bit.data is a generic pointer to the image data. Its content depends on the image type. Just cast it to the desired type to use it. For example if it's float (CV_32FC1):

int imW = img32bit.cols;
float *ptrF = (float*)img32bit.data;
float pix1015 = *(ptrF+10*imW+15); //get the value of pixel (10,15)
pix1015 = img32bit.at<float>(10,15); //same thing with at() function

For 8 bit RGB images:

Vec3b *ptrRGB = (Vec3b*)imgRGB.data;
*(ptrRGB+15*imW+20) = Vec3b(0,255,255); //set pixel (15,20) to yellow