Opencv旋转图像

来源:互联网 发布:粤贵银软件 编辑:程序博客网 时间:2024/06/05 11:42
  1. #include "stdafx.h"  
  2. #include "opencv2\core\core.hpp"  
  3. #include "opencv2\highgui\highgui.hpp"  
  4.   
  5. int main(   )   
  6. {  
  7.     cv::Mat image;  // create image  
  8.     cv::Mat result;  
  9.          
  10.         image = cv::imread("monument.jpg");    // open image  
  11.   
  12.     // check if image has been successfully read  
  13.     if (!image.data)    return 0;  
  14.   
  15.     cv:: cv::flip(image,result,1);///////////////  
  16.     cv::namedWindow("Flip Image"); // define the window  
  17.         cv::imshow("Flip Image", result); // display the Flip image  
  18.       
  19.     cv::waitKey(0); // wait for key pressed  
  20. }

flip(image,result,1);函数最后一个参数小于0时是将图像旋转180度,其他情况见图片

原始图片
  





             左右镜像对称图像(参数三大于0)



             镜像上下对称(参数三等于0)




                旋转180度(参数三小于0)

原创粉丝点击