• 3. 把一幅灰度图像进行旋转。


    #include <opencv/cv.h>
    
    #include <opencv/highgui.h>
    
    IplImage *rotateImage(const IplImage *src, int angleDegrees)
    
    {
    
    IplImage *imageRotated = cvCloneImage(src);
    
    if (angleDegrees != 0){
    
    CvMat* rot_mat = cvCreateMat(2, 3, CV_32FC1);
    
    CvPoint2D32f center = cvPoint2D32f(cvGetSize(imageRotated).width / 2, cvGetSize(imageRotated).height / 2);
    
    cv2DRotationMatrix(center, angleDegrees, 1, rot_mat);
    
    cvWarpAffine(src, imageRotated, rot_mat);
    
    }
    
    return imageRotated;
    
    }
    
     
    
     
    
    int main()
    
    {
    
    IplImage* img;
    
    IplImage* rotated_img;
    
    int angle = 0;
    
    img = cvLoadImage("6013202130.jpg");
    
    rotated_img = rotateImage(img, 223);
    
    cvNamedWindow("选做-图片旋转", CV_WINDOW_AUTOSIZE);
    
    cvNamedWindow("原图", CV_WINDOW_AUTOSIZE);
    
    cvShowImage("原图", img);
    
    cvShowImage("选做-图片旋转", rotated_img);
    
    cvWaitKey(0);//等待按键
    
    cvDestroyWindow("原图");
    
    cvDestroyWindow("选做-图片旋转");
    
    cvReleaseImage(&img);
    
    cvReleaseImage(&rotated_img);
    
    return 0;
    
    }
    
     

  • 相关阅读:
    hust 1605 bfs
    hdu 1512
    2013 ACMICPC 杭州现场赛 I题
    2013年 ACMICPC 杭州赛区H题
    hdu 3717 二分+队列维护
    hdu 2993 斜率dp
    hdu 3480 斜率dp
    hdu 3507 斜率dp
    hdu 2829 斜率DP
    零碎笔记
  • 原文地址:https://www.cnblogs.com/zhangfeionline/p/5465183.html
Copyright © 2020-2023  润新知