Access to the multichannel OpenCV element (C ++)

I am trying to use the "new" version 2.0 of C ++ OpenCV , but everything is like in a simple version of C. I have a problem with changing values ​​in the image.

Image CV_8UC3.

for (int i=0; i<image.rows; i++) { for (int j=0; j<image.cols; j++) { if (someArray[i][j] == 0) { image.at<Vec3i>(i,j)[0] = 0; image.at<Vec3i>(i,j)[1] = 0; image.at<Vec3i>(i,j)[2] = 0; } } } 

This does not work. What am I doing wrong?

Thanks!

+6
c ++ opencv
source share
1 answer

Aren't you using Vec3b instead of Vec3i ?

CV_8UC3 means your image has 8 bits, 3 channels, unsigned char. So far, Vec3i for the whole 3 channels, and Vec3b is for the 3 channels without the char sign.

So, I think you should use Vec3b

+14
source share

All Articles