Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

Your solution is nearly right, you just need to slice the correct region of interest of your output matrix, i.e. sth like this:

cv::Size sb_size(32,32);
std::vector<cv::Mat> small_blocks;

// ... do your block manipulations ...
// ... and save them to small_blocks ...

// now create combined image of all blocks
cv::Mat combined(256, 256, small_blocks[0].type());

for( size_t i = 0; i < small_blocks.size(); i++ ) 
{
  for  ( int y = 0; y < 256; y += sb_size.height )
  {
    for  ( int  x= 0 ; x < 256; x += sb_size.width )
    {
        // get the correct slice
        cv::Mat roi = combined(cv::Rect(x,y,sb_size.width,sb_size.height));
        small_blocks[i].copyTo(roi);
    }
  }
}