Ask Your Question

Revision history [back]

Using a vector of vec3b you can try :

    vector<Vec3b> v={Vec3b(0,1,2),Vec3b(3,4,5),Vec3b(6,7,8),Vec3b(10,11,12)};
    Mat x(v);
    cout<< x<<"\n";
    cout<<"row,col,channel = "<<x.rows<<" "<<x.cols<<" "<<x.channels()<<"\n";
    x = x.reshape(3,2);
    cout << x << "\n";
    cout << "row,col,channel = " << x.rows << " " << x.cols << " " << x.channels() << "\n";

and results are

[  0,   1,   2;
   3,   4,   5;
   6,   7,   8;
  10,  11,  12]
row,col,channel = 4 1 3
[  0,   1,   2,   3,   4,   5;
   6,   7,   8,  10,  11,  12]
row,col,channel = 2 2 3