Possible to devise iterator over NxN blocks in an image?

asked Nov 21 '13

mcow gravatar image

updated Nov 22 '13

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.

Preview: (hide)

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 (Nov 22 '13)edit
2

"Devise" is a verb.

mcow gravatar imagemcow (Nov 22 '13)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 (Nov 22 '13)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 (Nov 27 '13)edit