Ask Your Question

Revision history [back]

opencv 3.2 and C++. just do it !

Mat xt= (Mat_<double>(4,4 ) << 11, 12,13,14,21,22,23,24,31,32,33,34,41,42,43,44);
Mat xr=xt(Rect(0,0,3,3)).clone(); 
vector<double> lastCol;
lastCol = xt.colRange(Range(3, 4));
for (int ii=0;ii<4;ii++)
    cout<<lastCol[ii]<<"\t";
cout<<"\n";
cout<<xr;

opencv 3.2 and C++. just do it !

Mat xt= (Mat_<double>(4,4 ) << 11, 12,13,14,21,22,23,24,31,32,33,34,41,42,43,44);
Mat xr=xt(Rect(0,0,3,3)).clone(); 
vector<double> lastCol;
lastCol = xt.colRange(Range(3, 4));
for (int ii=0;ii<4;ii++)
    cout<<lastCol[ii]<<"\t";
cout<<"\n";
cout<<xr;

results :

xt = [11, 12, 13, 14;  
21, 22, 23, 24; 
31, 32, 33, 34;  
41, 42, 43, 44]
 14    24      34      44 
[11, 12, 13;  
21, 22, 23;  
31, 32, 33]

opencv 3.2 and C++. just do it !

Mat xt= (Mat_<double>(4,4 ) << 11, 12,13,14,21,22,23,24,31,32,33,34,41,42,43,44);
Mat xr=xt(Range(0,3),Range(0,3)).clone();//Mat xr=xt(Rect(0,0,3,3)).clone(); 
vector<double> lastCol;
lastCol = xt.colRange(Range(3, 4));
for (int ii=0;ii<4;ii++)
    cout<<lastCol[ii]<<"\t";
cout<<"\n";
cout<<xr;

results :

xt = [11, 12, 13, 14;  
21, 22, 23, 24; 
31, 32, 33, 34;  
41, 42, 43, 44]
 14    24      34      44 
[11, 12, 13;  
21, 22, 23;  
31, 32, 33]

opencv 3.2 and C++. just do it !

Matx44d xxt(11, 12,13,14,21,22,23,24,31,32,33,34,41,42,43,44);
Mat xt= (Mat_<double>(4,4 ) << 11, 12,13,14,21,22,23,24,31,32,33,34,41,42,43,44);
xt(xxt);
Mat xr=xt(Range(0,3),Range(0,3)).clone();//Mat xr=xt(Rect(0,0,3,3)).clone(); 
vector<double> lastCol;
lastCol = xt.colRange(Range(3, 4));
for (int ii=0;ii<4;ii++)
    cout<<lastCol[ii]<<"\t";
cout<<"\n";
cout<<xr;

results :

xt = [11, 12, 13, 14;  
21, 22, 23, 24; 
31, 32, 33, 34;  
41, 42, 43, 44]
 14    24      34      44 
[11, 12, 13;  
21, 22, 23;  
31, 32, 33]