Skip to content

Margus Roo –

If you're inventing and pioneering, you have to be willing to be misunderstood for long periods of time

  • Cloudbreak Autoscale fix
  • Endast

Tag: OpenCV

OpenCP cv:Mat and cv:transpose

Posted on November 14, 2017 - November 14, 2017 by margusja

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 🙂

Posted in LinuxTagged OpenCV

The Master

Categories

  • Apache
  • Apple
  • Assembler
  • Audi
  • BigData
  • BMW
  • C
  • Elektroonika
  • Fun
  • Hadoop
  • help
  • Infotehnoloogia koolis
  • IOT
  • IT
  • IT eetilised
  • Java
  • Langevarjundus
  • Lapsed
  • lastekodu
  • Linux
  • M-401
  • Mac
  • Machine Learning
  • Matemaatika
  • Math
  • MSP430
  • Muusika
  • neo4j
  • openCL
  • Õpetaja identiteet ja tegevusvõimekus
  • oracle
  • PHP
  • PostgreSql
  • ProM
  • R
  • Turvalisus
  • Varia
  • Windows
Proudly powered by WordPress | Theme: micro, developed by DevriX.