Possible to devise iterator over NxN blocks in an image?

asked 2013-11-21 17:41:23 -0600

mcow gravatar image

updated 2013-11-22 13:30:25 -0600

berak gravatar image

I'd like to do something like:

Mat foo(IMGSIZE, IMGSIZE, CV_MAKETYPE(CV_8U, 1), data);
typedef Matx<uint8_t, 4, 4> block;    // N=4
auto iblock = foo.begin<block>();
auto done = foo.end<block>();
while (iblock != done)
{
    Mat blk(*iblock);
    // process my 4x4 block
    ++iblock;
}

I think this should be possible, but not sure how.

edit retag flag offensive close merge delete

Comments

No clue what a devise iterator is, but it looks like your stuff can be solved with mask http://docs.opencv.org/doc/tutorials/core/mat-mask-operations/mat-mask-operations.html

Explain a bit better what you want to do

Moster gravatar imageMoster ( 2013-11-22 02:43:51 -0600 )edit
2

"Devise" is a verb.

mcow gravatar imagemcow ( 2013-11-22 13:04:20 -0600 )edit
2

@Moster, he wants to traverse the Mat not pixel by pixel, but in bigger chunks, like a 4x4 roi at a time. think of a grid.

berak gravatar imageberak ( 2013-11-22 13:24:00 -0600 )edit

Looking more closely at Matx, I don't think that structure is necessarily appropriate; an iterator that's based on Mat would work just as well for my purpose.

mcow gravatar imagemcow ( 2013-11-27 13:25:16 -0600 )edit