图像重映射

//opencv includes
#include"opencv2/core/utility.hpp"
#include <opencv2/core/core.hpp>
#include <opencv2/highgui/highgui.hpp>
#include<opencv2/imgproc/imgproc.hpp>
#include<opencv2/opencv.hpp>
#include<iostream>
//#include<random>

using namespace std;
using namespace cv;

void wave(const Mat &image, Mat &result)
{

	// 映射参数
	Mat srcX(image.rows, image.cols, CV_32F);
	Mat srcY(image.rows, image.cols, CV_32F);
	

	//创建映射参数
	for (int i = 0; i < image.rows;i++) 
	{
		for (int j = 0; j < image.cols;j++)
		{
		  srcX.at<float>(i,j)=j;
		  srcY.at<float>(i,j)=i+5 * sin(j / 10.0);
	 }
}
	//应用映射函数
	remap(image, result, srcX, srcY, INTER_LINEAR);
}


int main()
{
	//打开图像
	Mat image = imread("C:\\Users\\Administrator\\Desktop\\xiaohai.jpg", 1);
	if (image.empty())
	{
		cout << "Error!cannot be read....../n";
		return -1;
	}

	Mat result;
	//调用函数
	wave(image,result);

	//显示结果
	namedWindow("result");
	imshow("result", result);
	waitKey(0);

	system("pause");
	return 0;

}



![原图](https://img-blog.csdnimg.cn/dbaa54706e8b44048f8525a31cf8c2e9.jpg#pic_center)
![波浪处理后](https://img-blog.csdnimg.cn/5f9b798e235d44209130fa70d3952e30.png#pic_center)


更多推荐