Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

Resize Mat error components

I want to resize a matrix but the components are diferents. This is the code

int p = 0;
Mat A = Mat(20,20, CV_64F);
for (int i = 0; i < 20; i++)
{
    for (int j = 0; j < 20; j++)
    {
        A.at<double>(i, j) = p;
        p++;
    }
}
cout << A <<endl;

Mat m = A.col(0);
for(int i=0;i<A.cols-1;i++)
vconcat(m, A.col(i+1), m);

Mat z = m(Range(0, 4), Range(0, 1));
Mat dest;
cout << z <<endl;
resize(z, dest, cv::Size(2, 2));
cout << dest <<endl;

and this the output:

[0;
 20;
 40;
 60]
[10, 10;
 50, 50]

The first output is a matrix z, and the sencond is matrix is produce by the resizing of the mat z.