Hello I have a matrix M 3x3
I use reshape(0,9) so the M.at(0,1) should be the 4th element but it becomes the 2nd element. Help please. If i am wrong then please tell me how do i convert a 2D matrix into a 1D column vector.
1 | initial version |
Hello I have a matrix M 3x3
I use reshape(0,9) so the M.at(0,1) should be the 4th element but it becomes the 2nd element. Help please. If i am wrong then please tell me how do i convert a 2D matrix into a 1D column vector.
2 | No.2 Revision |
Hello I have a matrix M 3x3
I use reshape(0,9) so the M.at(0,1) should be the 4th element but it becomes the 2nd element. Help please. If i am wrong then please tell me how do i convert a 2D matrix into a 1D column vector.
EDIT: I dunno how to show the code. Its too big
My matrix is 92 x 112. some of the data below.
-40 -39
-44
....
In matlab if i reshape it becomes
-40
-44
...
-39
-39 becomes the 93rd element. In opencv I reshape it becomes
-40
-39
....
-39 becomes the SECOND element and i dunno where the -44 goes to
3 | No.3 Revision |
Hello I have a matrix M 3x3
I use reshape(0,9) so the M.at(0,1) should be the 4th element but it becomes the 2nd element. Help please. If i am wrong then please tell me how do i convert a 2D matrix into a 1D column vector.
EDIT: I dunno how to show the code. Its too big
My matrix is 92 x 112. some of the data below.
-40 -39
-44
....
In matlab if i reshape it becomes
-40
-44
...
-39
-39 becomes the 93rd element. In opencv I reshape it becomes
-40
-39
....
-39 becomes the SECOND element and i dunno where the -44 goes toto. I used M.reshape(0,92*112)
4 | No.4 Revision |
Hello I have a matrix M 3x3
I use reshape(0,9) so the M.at(0,1) should be the 4th element but it becomes the 2nd element. Help please. If i am wrong then please tell me how do i convert a 2D matrix into a 1D column vector.
EDIT: I dunno how to show the code. Its too big
My matrix is 92 x 112. some of the data below.
-40 -39
-44
....
In matlab if i reshape it becomes
-40
-44
...
-39
-39 becomes the 93rd element. In opencv I reshape it becomes
-40
-39
....
-39 becomes the SECOND element and i dunno where the -44 goes to. I used M.reshape(0,92*112)M.reshape(0,92*112). Matlab is giving me the right answer
5 | No.5 Revision |
Hello I have a matrix M 3x3
I use reshape(0,9) so the M.at(0,1) should be the 4th element but it becomes the 2nd element. Help please. If i am wrong then please tell me how do i convert a 2D matrix into a 1D column vector.
EDIT: I dunno how to show the code. Its too big
My matrix is 92 x 112. some of the data below.
-40 -39
-44
....
In matlab if i reshape it becomes
-40
-44
...
-39
-39 becomes the 93rd element. In opencv I reshape it becomes
-40
-39
....
-39 becomes the SECOND element and i dunno where the -44 goes to. I used M.reshape(0,92*112). Matlab is giving me the right answer
Here is the short piece of code that I have
cout << Im.at<float>(0,0) << endl;
cout << Im.at<float>(0,1) << endl;
waitKey(0);
// Reshape to column vector -- Wrong
Mat temp;
Im.reshape(1, 92*112).copyTo(temp);
cout << temp.at<float>(0,0) << endl;
cout << temp.at<float>(1,0) << endl;
What I am getting above is that the elements in (0,0) and (0,1) are equal to (0,0) and (1,0) after being reshaped.
6 | No.6 Revision |
Hello I have a matrix M 3x3
I use reshape(0,9) so the M.at(0,1) should be the 4th element but it becomes the 2nd element. Help please. If i am wrong then please tell me how do i convert a 2D matrix into a 1D column vector.
EDIT: I dunno how to show the code. Its too big
My matrix is 92 x 112. some of the data below.
-40 -39
-44
....
In matlab if i reshape it becomes
-40
-44
...
-39
-39 becomes the 93rd element. In opencv I reshape it becomes
-40
-39
....
-39 becomes the SECOND element and i dunno where the -44 goes to. I used M.reshape(0,92*112). Matlab is giving me the right answer
Here is the short piece of code that I have
cout << Im.at<float>(0,0) << endl;
cout << Im.at<float>(0,1) << endl;
waitKey(0);
// Reshape to column vector -- Wrong
Mat temp;
Im.reshape(1, Im.reshape(0, 92*112).copyTo(temp);
cout << temp.at<float>(0,0) << endl;
cout << temp.at<float>(1,0) << endl;
What I am getting above is that the elements in (0,0) and (0,1) are equal to (0,0) and (1,0) after being reshaped.
7 | No.7 Revision |
Hello I have a matrix M 3x3
I use reshape(0,9) so the M.at(0,1) should be the 4th element but it becomes the 2nd element. Help please. If i am wrong then please tell me how do i convert a 2D matrix into a 1D column vector.
EDIT: I dunno how to show the code. Its too big
My matrix is 92 x 112. some of the data below.
-40 -39
-44
....
In matlab if i reshape it becomes
-40
-44
...
-39
-39 becomes the 93rd element. In opencv I reshape it becomes
-40
-39
....
-39 becomes the SECOND element and i dunno where the -44 goes to. I used M.reshape(0,92*112). Matlab is giving me the right answer
Here is the short piece of code that I have
cout << Im.at<float>(0,0) << endl;
cout << Im.at<float>(0,1) << endl;
waitKey(0);
// Reshape to column vector -- Wrong
Mat temp;
Im.reshape(0, 92*112).copyTo(temp);
cout << temp.at<float>(0,0) << endl;
cout << temp.at<float>(1,0) << endl;
What I am getting above is that the elements in (0,0) and (0,1) are equal to (0,0) and (1,0) after being reshaped. Im(0,1) should be equal to temp(113,0) or temp(93,0) but I am not getting such values.
8 | No.8 Revision |
Hello I have a matrix M 3x3
I use reshape(0,9) so the M.at(0,1) should be the 4th element but it becomes the 2nd element. Help please. If i am wrong then please tell me how do i convert a 2D matrix into a 1D column vector.
EDIT: I dunno how to show the code. Its too big
My matrix is 92 x 112. some of the data below.
-40 -39
-44
....
In matlab if i reshape it becomes
-40
-44
...
-39
-39 becomes the 93rd element. In opencv I reshape it becomes
-40
-39
....
-39 becomes the SECOND element and i dunno where the -44 goes to. I used M.reshape(0,92*112). Matlab is giving me the right answer
Here is the short piece of code that I have
cout << Im.at<float>(0,0) << endl;
cout << Im.at<float>(0,1) << endl;
waitKey(0);
// Reshape to column vector -- Wrong
Mat temp;
Im.reshape(0, 92*112).copyTo(temp);
cout << temp.at<float>(0,0) << endl;
cout << temp.at<float>(1,0) << endl;
What I am getting above is that the elements in (0,0) and (0,1) are equal to (0,0) and (1,0) after being reshaped. Im(0,1) should be equal to temp(113,0) or temp(93,0) but I am not getting such values.values. Is there another function to reshape a 2D Mat ?
9 | No.9 Revision |
Hello I have a matrix M 3x3
I use reshape(0,9) so the M.at(0,1) should be the 4th element but it becomes the 2nd element. Help please. If i am wrong then please tell me how do i convert a 2D matrix into a 1D column vector.
EDIT: I dunno how to show the code. Its too big
My matrix is 92 x 112. some of the data below.
-40 -39
-44
....
In matlab if i reshape it becomes
-40
-44
...
-39
-39 becomes the 93rd element. In opencv I reshape it becomes
-40
-39
....
-39 becomes the SECOND element and i dunno where the -44 goes to. I used M.reshape(0,92*112). Matlab is giving me the right answer
Here is the short piece of code that I have
cout << Im.at<float>(0,0) << endl;
cout << Im.at<float>(0,1) << endl;
waitKey(0);
// Reshape to column vector -- Wrong
Mat temp;
Im.reshape(0, 92*112).copyTo(temp);
cout << temp.at<float>(0,0) << endl;
cout << temp.at<float>(1,0) << endl;
What I am getting above is that the elements in (0,0) and (0,1) are equal to (0,0) and (1,0) after being reshaped. Im(0,1) should be equal to temp(113,0) or temp(93,0) but I am not getting such values. Is there another function to reshape a 2D Mat ?
EDIT: Okay it seems like my understanding of the reshape function was totally wrong. Thanks again berak. I had thought OpenCV would go 'down' the array but it seems like OpenCV would move from top left to bottom right