I want to divide a simple Mat
(200x200) in different regions (10x10).
I make 2 loops, then I create a Rect
where I indicate the variables I want in each iteration (x, y, width, height)
. Finally, I save this region of the image inside a vector
of Mat
s.
But something is wrong with my code:
Mat face = Mat(200, 200, CV_8UC1);
vector<Mat> regions;
Mat region_frame;
int width = face.cols * 0.05;
int heigth = face.rows * 0.05;
for(int y=0; y<=(face.rows - heigth); y+=heigth)
{
for(int x=0; x<=(face.cols - width); x+=width)
{
Rect region = Rect(x, y, x+width, y+heigth);
region_frame = face(region);
regions.push_back(region_frame);
}
}
The problem is just in the final step, it's not working with size of the new region_frame
I try to create. It's increasing with each iteration number of cols.
How can I solve this?