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_
You need some kind of counting variable and you will have to declare and update it yourself. A compact way of doing this would be
int i = 0;
for( it = I.begin(), end = I.end(); it != end; ++it,i++)
{
//some codes here involving i+2 and i+3
}
if you are looking for super fast access however I would recommend manipulating the data pointer yourself. For a great explanation of iterating speed look at OpenCV 2 Computer Vision Application Programming Cookbook on page 51 (65 in pdf). Your code might then look something lik
cv::Mat your_matrix;
//assuming you are using uchar
uchar* data = your_matrix.data();
for(int i = 0; i < some_number; i++)
{
//operations using *data
data++;
}