Ask Your Question

Revision history [back]

Iterate matrix and copy out

Hi all, Hi all, I have a problem with some matrix operations. I have one matrix MatOriginal and I want copy out into another one, only the range from (0,0) to (300,300). So I try to iterate the original one (MatOriginal) and copy out, my code is:

a = 0; b = 0;

    for(int x = 0; x < 300; x++)
    {
        for(int y = 0; y < 300; y++)
        {
            MatNew.at<int>(a,b) = MatOriginal.at<int>(x,y);
            a++;
        }

        b++;
    }

But this doesn't works... anyone can help me please?