Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

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.

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.