OpenCv 013---图像的翻转

1 前备知识

null

2 所用到的主要OpenCv API

/** @brief Flips a 2D array around vertical, horizontal, or both axes.

@param src input array.
@param dst output array of the same size and type as src.
@param flipCode a flag to specify how to flip the array; 0 means
flipping around the x-axis and positive value (for example, 1) means
flipping around y-axis. Negative value (for example, -1) means flipping
around both axes.
@sa transpose , repeat , completeSymm
*/

CV_EXPORTS_W void flip(InputArray src, OutputArray dst, int flipCode);

3 程序代码

#include<opencv2\opencv.hpp>
#include<iostream>

using namespace std;
using namespace cv;

int main(int argc, char** argv)
{
    Mat src = imread("G:\\CVworkstudy\\program_wwx\\研习社140课时\\ZhaiZhigang140\\lena.jpg");
    if (src.empty())
    {
        cout << "Could not load image..." << endl;
        return false;
    }
    namedWindow("srcImg");
    imshow("srcImg", src);
    Mat flipX, flipY, flipXY;
    //延X轴镜像翻转
    flip(src, flipX, 0);
    //延Y轴镜像翻转
    flip(src, flipY, 1);
    //延XY方向镜像翻转(对角翻转)
    flip(src, flipXY, -1);
    //结果显示
    imshow("flipXDst", flipX);
    imshow("flipYDst", flipY);
    imshow("flipXYDst", flipXY);

    waitKey(0);
    return 0;
}

4 运行结果

 

 

5 扩展及注意事项

null

posted @ 2019-07-14 10:44  鸡鸣昧旦  阅读(377)  评论(0编辑  收藏  举报