OpenCV image matrix inversion, transposition, and rotation special

Disclaimer: This article is a blogger original article, shall not be reproduced without the bloggers allowed. https://blog.csdn.net/qq_33810188/article/details/83542835

And the image inversion function transposed in OpenCV may be convenient for the image rotation angle of the special!

Image flip function

cv::flip(mat_src,mat_dst,flag)

among them,

flag = 0 about the X axis (horizontal axis) Flip

Flip flag> 0 around the Y-axis (vertical axis)

flag <0 simultaneously about the X and Y axes flipping

The image transposition function

cv :: tranpose (mat_src, mat_dst); // change the main diagonal, the diagonal sub-swap

Image inversion function and the function of a combination use of transposition, the image may be a special effect rotation angle!

Function to achieve the following effects:

-------------------------------------------------

Original:

-------------------------------------------------

Flip picture about the X axis:

cv::flip(mat,mat,0);

-------------------------------------------------

Flip picture about the Y axis:

cv::flip(mat,mat,1);

-------------------------------------------------

Around the original X and Y axes at the same time flipping:

cv::flip(mat,mat,-1);

-------------------------------------------------

Original transpose:

cv::tranpose(mat,mat);

-------------------------------------------------

Picture rotated clockwise by 90 degrees:

cv::transpose(mat,mat);

cv::flip(mat,mat,1);

-------------------------------------------------

Picture is rotated counterclockwise by 90 degrees:

cv::transpose(mat,mat);

cv::flip(mat,mat,0);

-------------------------------------------------

 

 

Guess you like

Origin blog.csdn.net/qq_33810188/article/details/83542835