OpenCV: Matrix Iteration

Viewed 28285

I am new to OpenCV. I am trying to use iterator instead of "for" loop, which is too slow for my case. I tried some codes like this:

MatIterator_<uchar> it, end;
for( it = I.begin<uchar>(), end = I.end<uchar>(); it != end; ++it)
{
    //some codes here
}

My question here is: how can I convert a for loop like:

for ( int i = 0; i < 500; i ++ )
{
    exampleMat.at<int>(i) = srcMat>.at<int>( i +2, i + 3 )
}

into iterator mode? That is, how can I do the "i +2, i + 3" in iterator form? I only can get the corresponding value by " *it " I think, but I couldn't get its counting number. Many thanks in advance.

2 Answers
Related