OpenCV (c++) multi channel element access

I'm trying to use the "new" 2.0 c++ version of OpenCV, but everything is else like in simple C version. I have some problem with changing the values in image.

The image is 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;
        }
    }
}

It's not working. What am I doing wrong???

Thank you!

Answers


Shouldn't you be using Vec3b instead of Vec3i ?

CV_8UC3 means your image is 8 bit, 3 channels, unsigned char. While Vec3iis for 3 channels integers and Vec3bis for 3 channels unsigned char.

So I think you should be using Vec3b


Need Your Help

C: character comparison fails

c entab-detab

After succesfully running an entabulator, my detabulator won't pick up on a character comparison that should exit a while loop. After trying "0(tab)8(enter)(ctrl+D)" as input the tab is written cor...

How can I modify an existing UIViewController to allow scrolling?

iphone uiview uiviewcontroller interface-builder uiscrollview

I have already built a UIViewController subclass with a bunch of controls in it, and just realized that if I rotate the iPhone, half of the controls become invisible. So, I would like to somehow ma...