Matrix transpose does some cool stuff with matrix elements. In example using OpenCV:
Mat A = (Mat_<float>(2, 5) << 1, 2, 3, 4, 5, 7, 8, 9, 10, 11);
cout << “A = “ << endl << ” “ << A << endl << endl;
Mat A1;
transpose(A, A1);
cout << “A1 = “ << endl << ” “ << A1 << endl << endl;
A =
[1, 2, 3, 4, 5;
7, 8, 9, 10, 11]
A1 =
[1, 7;
2, 8;
3, 9;
4, 10;
5, 11]
Nice yeah.
As OpenCV holds pictures as matrixes then lets find out what is turns out to transpose image.
Picture has a little more matrix elements than in a previous example –
Image heigth: 720 cols: 1080 – It means 720 x 1080 elements.
// Load an color image in grayscale
Mat img = imread(“/Users/margusja/Pictures/faces/margusja2.jpg”,0);
cv::Size s = img.size();
int rows = s.height;
int cols = s.width;
Mat fimage;
transpose(img, fimage);
cout << “Image heigth: “ << rows << ” cols: “ << cols << endl;
namedWindow( “Display window”, WINDOW_AUTOSIZE );
imshow(“Margusja 1”,img);
namedWindow( “Display window”, WINDOW_AUTOSIZE );
imshow(“Margusja transposed”,fimage);
And result:
Versus
Now we have a clue how they rotate our pictures 🙂