opencv中,图像的翻转,图像没有显示出来,只显示出Usage: invImage lena.jpg请大家帮下忙,谢谢……

发布网友 发布时间:2022-04-26 09:23

我来回答

2个回答

热心网友 时间:2023-10-09 05:20

 试试高版本的openCV吧,Mat比IplImage好用多了。帮你写了下


#include <opencv2\opencv.hpp>  
#include<iostream>
using namespace cv;
#include "stdafx.h"
int _tmain(int argc, _TCHAR* argv[])
{
    Mat img;
    img = imread("D:\\download\\logo.png");
    imshow("show", img);
    for (int i = 0; i < img.rows; i++)
        for (int j = 0; j < (img.cols/2); j++)
        {
            int tmpB = img.at<Vec3b>(i, j)[0];
            int tmpG = img.at<Vec3b>(i, j)[1];
            int tmpR = img.at<Vec3b>(i, j)[2];
            img.at<Vec3b>(i, j)[0] = img.at<Vec3b>(i, img.cols - j - 1)[0];
            img.at<Vec3b>(i, j)[1] = img.at<Vec3b>(i, img.cols - j - 1)[1];
            img.at<Vec3b>(i, j)[2] = img.at<Vec3b>(i, img.cols - j - 1)[2];
            img.at<Vec3b>(i, img.cols - j - 1)[0] = tmpB;
            img.at<Vec3b>(i, img.cols - j - 1)[1] = tmpG;
            img.at<Vec3b>(i, img.cols - j - 1)[2] = tmpR;
        }
    imshow("spieglt", img);
    waitKey();
    return 0;
}

热心网友 时间:2023-10-09 05:20

if(argc<2),你这样写是需要从控制台命令窗口调用程序并传入参数的

声明声明:本网页内容为用户发布,旨在传播知识,不代表本网认同其观点,若有侵权等问题请及时与本网联系,我们将在第一时间删除处理。E-MAIL:11247931@qq.com