学习OpenCV:滤镜系列(7)——漩涡

==============================================

版权所有:小熊不去实验室CSDN博客

==============================================


设图象的漩涡中心为o,设p为图像任意点,只要对p做绕o的旋转,且旋转角随p-o距离的增加而减少,就是"漩涡"变换了.


#include
#include 
#include 

using namespace cv;
using namespace std;

template T sqr(T x){return x*x;}

double Pi=3.14;

double Para=20;

int main()
{
	Mat src = imread("D:/img/face01.jpg",1);
	int heigh = src.rows;
	int width = src.cols;
	Point center(width/2, heigh/2);
	Mat img;
	src.copyTo(img);
	Mat src1u[3];
	split(src,src1u);

	for (int y=0; y(y);
		uchar* srcP = src.ptr(y);
		for(int x=0; xwidth-1) newX=width-1;
			if(newY<0) newY=0;
			if(newY>heigh-1) newY=heigh-1;

			imgP[3*x] = src1u[0].at(newY,newX);
			imgP[3*x+1] = src1u[1].at(newY,newX);
			imgP[3*x+2] = src1u[2].at(newY,newX);
		}
	}
	imshow("vortex",img);
	waitKey();
	imwrite("D:/img/漩涡.jpg",img);
}

原图:

学习OpenCV:滤镜系列(7)——漩涡_第1张图片

漩涡:

学习OpenCV:滤镜系列(7)——漩涡_第2张图片


你可能感兴趣的:(滤镜,OpenCV,图像滤镜)