Thursday, October 27, 2005

rgb opencv pixel values (bgr)

The correct channel sequence for an RGB image is B, G, R.

img->imageData + img->widthStep*pt.y + pt.x*3 is the Blue channel address,
img->imageData + img->widthStep*pt.y + pt.x*3 + 1 is Green
img->imageData + img->widthStep*pt.y + pt.x*3 + 2 is Red

so if want the blue image:
((uchar*)(img->imageData + img->widthStep*pt.y))[pt.x*3 + 0] =0xFF;//255

No comments:

Post a Comment