绕X轴Y轴旋转图像

常用此功能进行图像格式变换,也就是坐标原点在左上角和右下角的变换

核心函数:cvFlip

程序:

wKioL1PsX6DySI9HAAF52q-bY7I209.jpg

#include "cv.h"
#include "cxcore.h"
#include "highgui.h"
#include <iostream>
int test(int argc,char** argv)
{
IplImage* src=cvLoadImage("e:\\picture\\4.jpg");
IplImage* dst1=cvCreateImage(cvGetSize(src),src->depth,src->nChannels);
IplImage* dst2=cvCreateImage(cvGetSize(src),src->depth,src->nChannels);
IplImage* dst3=cvCreateImage(cvGetSize(src),src->depth,src->nChannels);
cvFlip(src,dst1,0);  //绕X轴旋转
cvFlip(src,dst2,1);  //绕Y轴旋转
cvFlip(src,dst3,-1);  //绕X轴和Y轴旋转
cvNamedWindow("src");
cvNamedWindow("dst1");
cvNamedWindow("dst2");
cvNamedWindow("dst3");
cvShowImage("src",src);
cvShowImage("dst1",dst1);
cvShowImage("dst2",dst2);
cvShowImage("dst3",dst3);
cvWaitKey(0);
cvDestroyWindow("src");
cvDestroyWindow("dst1");
cvDestroyWindow("dst2");
cvDestroyWindow("dst3");
cvReleaseImage(&src);
cvReleaseImage(&dst1);
cvReleaseImage(&dst2);
cvReleaseImage(&dst3);
return 0;
}


你可能感兴趣的:(opencv,绕X轴Y轴旋转图像)