// define head function
#ifndef PS_ALGORITHM_H_INCLUDED
#define PS_ALGORITHM_H_INCLUDED #include <iostream>
#include <string>
#include "cv.h"
#include "highgui.h"
#include "cxmat.hpp"
#include "cxcore.hpp"
#include "math.h" using namespace std;
using namespace cv; void Show_Image(Mat&, const string &); #endif // PS_ALGORITHM_H_INCLUDED #include "PS_Algorithm.h"
#include <time.h> using namespace std;
using namespace cv; #define pi 3.1415926 int main()
{
string Img_name("4.jpg");
Mat Img;
Img=imread(Img_name); Mat Img_out(Img.size(), CV_8UC3);
Img.copyTo(Img_out); int width=Img.cols;
int height=Img.rows;
int N=30; Point Center(width/2, height/2); float new_x,new_y;
float p,q,x1,y1,x0,y0; for (int y=0; y<height; y++)
{
for (int x=0; x<width; x++)
{
y0=Center.y-y;
x0=x-Center.x; new_x=N*sin(2*pi*y0/128.0)+x0;
new_y=N*cos(2*pi*x0/128.0)+y0; new_x=Center.x+new_x;
new_y=Center.y-new_y; if(new_x<0) new_x=0;
if(new_x>=width-1) new_x=width-2;
if(new_y<0) new_y=0;
if(new_y>=height-1) new_y=height-2; x1=(int)new_x;
y1=(int)new_y; p=new_x-x1;
q=new_y-y1; for (int k=0; k<3; k++)
{
Img_out.at<Vec3b>(y, x)[k]=(1-p)*(1-q)*Img.at<Vec3b>(y1, x1)[k]+
(p)*(1-q)*Img.at<Vec3b>(y1,x1+1)[k]+
(1-p)*(q)*Img.at<Vec3b>(y1+1,x1)[k]+
(p)*(q)*Img.at<Vec3b>(y1+1,x1+1)[k];
} }
} Img_out=Img_out;
Show_Image(Img_out, "out"); imwrite("Out.jpg", Img_out); waitKey(); } // define the show image
#include "PS_Algorithm.h"
#include <iostream>
#include <string> using namespace std;
using namespace cv; void Show_Image(Mat& Image, const string& str)
{
namedWindow(str.c_str(),CV_WINDOW_AUTOSIZE);
imshow(str.c_str(), Image); }

原图

效果图

最新文章

  1. HVTableView 分享组
  2. 《JAVA学习笔记 (final关键字)》
  3. IOS中调用系统的电话、短信、邮件、浏览功能
  4. centos7 搭建docker内运行rabbitmq,然后再镜像ha方案的完全教程,暂时一个宿主机只能运行一个docker的rabbitmq,但是集群 ha都正常
  5. 2.1.6 用ProtectX实现扫描的反击与追踪
  6. 【PHPsocket编程专题(实战篇③)】构建基于socket的HTTP请求类
  7. dapper 写查询sql 时,多条件参数操作方法
  8. ThinkPHP3.1新特性:Action参数绑定
  9. sqltext sqlarea
  10. Android使用应用程序资源(、颜色数组、尺寸、弦、布尔、整型)
  11. Spring源码解析三:IOC容器的依赖注入
  12. Servlet--ServletInputStream类,ServletOutputStream类
  13. 服务端渲染和nuxt简单介绍
  14. 【BZOJ3730】震波(动态点分治)[复习]
  15. linux下设置mysql5.7数据库远程访问
  16. suoi63 树与路径 (倍增lca)
  17. 洛谷P1247 取火柴游戏
  18. C# winForm webBrowser页面中js调用winForm类方法(转)
  19. 机器学习之k-最近邻(kNN)算法
  20. HTML5 表单 中

热门文章

  1. int a; int* a; int** a; int (*a)[]; int (*a)(int)
  2. 命令行编译sass
  3. (二)关于jQuery
  4. 《textanalytics》课程简单总结(2):topic mining
  5. Chrome自带恐龙小游戏的源码研究(七)
  6. canvas drawImage方法不显示图片的解决方案
  7. 有关SQL注入的知识
  8. 计算两个GPS坐标点的距离
  9. C语言高速入门系列(四)
  10. eval(function(p,a,c,k,e,d){e=function(c)加解密