Convert imread output to vector

Hi to all!
I want to convert the output of Mat imageIn = imread(argv[1], IMREAD_UNCHANGED);
in my code to std::vector<int in order to use it as a a vector.
Any help would be precious.
Thnanks ina advance.

You can use copyTo method :

vector<int> v;
Mat a = (Mat_<float>(2, 3) << 0, 1.1, 2, 10, 11, 12);
cout << "Original a = \n" << a << "\n";
Mat b = a.reshape(1, 1);
cout << "Reshape a : b = \n" << b << "\n";
b.copyTo(v);
for (auto i : v)
    cout << i << "\t";
1 Like

Thanks for your reply!
Forgot to mention that i use C++…