image step not continuous after dividing an image
Hi everyone,
I am try to divide an image into blocks in opencv and i get the "Error image step is not continuous". Pls here is my code need your help.
vector<Mat> ilmage;
int N = (images[0].cols * images[0].rows) / (x*y);
Mat t;
int m = images[0].rows / x;
int n = images[0].cols / y;
int i2, i3, i4, i5;
Size smallsize(n, m);
for (int i = 0; i < images.size(); i++){
for (int j = 0; j < images[i].rows; j += smallsize.height){
for (int k = 0; k < images[i].cols; k += smallsize.width ){
//i2 = k*n, i3 = n, i4 = j*m; i5 = m;
t = images[i](Rect(k, j, smallsize.width,smallsize.height));
ilmage.push_back(transpose(t.reshape(0, N)));
}
}
pImage.push_back(ilmage);
ilmage.clear();
}
Regards.
i did not try your code. i suggest you to try
@berak could you convert your comment as answer
i got another idea: @valentine, would you apply the proposed changes, and submit the successful results as an answer ?
Its working now. i had to clone the image before reshaping. @berak the x and y values are the different blocks am dividing the cols and rows of the image into. Thanks sturkmen and berak.