OpenCV数字图像处理六:图像垂直翻转

来源:互联网 发布:知乎女神芈十四真名 编辑:程序博客网 时间:2024/06/06 07:20
OpenCV数字图像处理六:图像垂直翻转
959人阅读 评论(0)收藏举报
本文章已收录于:
分类:
作者同类文章X
    /*OpenCV2.4.3*/


    #include "stdafx.h"
    #include "opencv2/highgui/highgui.hpp"
    #include "opencv2/imgproc/imgproc.hpp"
    #include <iostream>
    #include <stdio.h>


    using namespace cv;


    /// Global variables
    Mat src, dst;


    Mat map_x, map_y;


    char* remap_window = "RotateImage";


    int ind = 0;


    /// Function Headers
    void update_map( void );


    int main( int argc, char** argv )
    {
    /// Load the image
    src = imread("test.jpg");


    /// Create dst, map_x and map_y with the same size as src:
    dst.create( src.size(), src.type() );
    map_x.create( src.size(), CV_32FC1 );
    map_y.create( src.size(), CV_32FC1 );


    /// Create window
    namedWindow( remap_window, CV_WINDOW_AUTOSIZE );


    /// Update map_x & map_y. Then apply remap
    for( int j = 0; j < src.rows; j++ ){ 
    for( int i = 0; i < src.cols; i++ ){
    map_x.at<float>(j,i) = src.cols - i ;
    map_y.at<float>(j,i) = src.rows - j ;
    }
    }


    remap( src, dst, map_x, map_y, CV_INTER_LINEAR, BORDER_CONSTANT, Scalar(0,0, 0) );


    /// Display results
    imshow( remap_window, dst );
    imwrite("rotateImage.jpg",dst);
    cv::waitKey(0);
    return 0;
    }
    0
    0
     
     




    0 0