开发者

OpenCV selecting proper submatrix in loop with C++

I'm fairly new to opencv. I'm trying to write a loop that does some processing on a small (9x9) submatrix of a large (~1000 x ~1000) matrix. Based on some mask matrix I decided whether or not to process the 9x9 at a particular point in the large matrix. Based on the documentation I read I'm trying to put this line of code inside a loop:

Mat tempROI(*(data->cvData), Rect(i-4,j-4, i+5, j+5));

i and j are row,col indecies of the larger matrix. I then have a function that processes tempROI. I'm finding, however, that the size of my ROI is increasing with i and j. I dumped a:

printf("Size of ROI = %d, %d.\nFor IDX开发者_JAVA百科 = %d, %d\n", tempROI.rows, tempROI.cols, i, j);

into the loop to debug. I see that my ROI is increasing significantly. For example here's a random dump:

Size of ROI = 191, 9. For IDX = 4, 186

Clearly something's not working properly and I think it's a fair assumption that the fallacy lies in my understanding of how to properly select a submatrix from a larger one. Can someone advise as to what the best way to go about this is?

On a related note I was really hoping to just use a pointer as opposed to actually creating the matrix header every loop iteration.

In short - what's the right way to do what I'm trying to do? Thanks a lot.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜