// 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 /* generate the circle transform
*/ #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); int width=Img.cols;
int height=Img.rows; float angle = 0;
float centreX = 0.5;
float centreY = 1.0;
float radius = 150;
float high=200;
float spreadAngle=pi; float icentreX=width*centreX;
float icentreY=height*centreY;
float radius2=radius*radius; float dx,dy,new_x,new_y;
float p,q,x1,y1;
float r, theta; for (int y=0; y<height; y++)
{
for (int x=0; x<width; x++)
{ dx=x-icentreX;
dy=y-icentreY; theta=atan2(-dy, -dx)+angle;
r=sqrt(dy*dy+dx*dx); theta=std::fmod(theta,(float)2*pi); new_x=width * theta/(spreadAngle+0.00001);
new_y=height * (1-(r-radius)/(high+0.00001)); // 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; if (new_x<0) continue;
if (new_x>=width-1) continue;
if (new_y>=height-1) continue;
if (new_y<0) continue; 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];
} }
} Show_Image(Img_out, "out");
cout<<"All is well"<<endl; // 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); }

图像效果可以参考:

http://blog.csdn.net/matrix_space/article/details/46789467

Opencv— — Circle Filter的更多相关文章

  1. Opencv— — kaleidoscope Filter

    // define head function #ifndef PS_ALGORITHM_H_INCLUDED #define PS_ALGORITHM_H_INCLUDED #include < ...

  2. Opencv— — Pinch Filter

    // define head function #ifndef PS_ALGORITHM_H_INCLUDED #define PS_ALGORITHM_H_INCLUDED #include < ...

  3. Opencv— — Twirl Filter

    // define head function #ifndef PS_ALGORITHM_H_INCLUDED #define PS_ALGORITHM_H_INCLUDED #include < ...

  4. [D3] 13. Cleaner D3 code with selection.call()

    selection.call() method in D3 can aid in code organization and flexibility by eliminating the need t ...

  5. d3js selections深入理解

    D3 selections选择DOM元素以便可以对这些dom元素做相应的操作,比如:更改其style,修改其属性,执行data-join操作,或者插入.删除相应elements 比如,如果给定5个ci ...

  6. [D3] Debug D3 v4 with Dev Tools

    Since D3 outputs standard markup, you can use familiar dev tools and inspectors to debug your visual ...

  7. 【Python】PIL模块

    Python自建库,在爬虫等基础应用中更加简单好记,做整理以备自查. 目录 Image模块 open类.Save类.format类.Mode类.convert类.Size类.Info类.new类.Co ...

  8. 使用CSS实现多种Noise噪点效果

    声明:本文涉及图文和模型素材仅用于个人学习.研究和欣赏,请勿二次修改.非法传播.转载.出版.商用.及进行其他获利行为. 背景 在插画中添加噪点肌理可以营造出一种自然的氛围.噪点肌理可以用于塑造阴影.高 ...

  9. django 操作数据库--orm(object relation mapping)---models

    思想 django为使用一种新的方式,即:关系对象映射(Object Relational Mapping,简称ORM). PHP:activerecord Java:Hibernate C#:Ent ...

随机推荐

  1. phonegap工程搭建基础(一)

      官网:http://cordova.apache.org   一.环境配置 1. 安装Cordova   on OS X and Linux: $ sudo npm install -g cord ...

  2. PS 如何用PS制作GIF图像

    首先我们准备好要依次播放的图片(这里使用的是CS的光标缩放,只有两张图) 然后在窗口中打开动画,则下方会出现动画的面板. 点击图层按钮可以添加一帧,我们让第一帧显示为大图片,第二帧为小图片.还可以设置 ...

  3. mac os PHP 访问MSSQL

    写在前: 项目的数据库是sql server,但是自己的系统是mac os.这样导致了需要一个烦人的系统环境搭建过程.目前要在mac 上的php环境中支持mssql环境访问,经过自己了解,有两种方式: ...

  4. Java泛型 类型变量的限定

    有时候,类和方法须要对类型变量加以约束.比方你有一个方法,你仅仅希望它接收某个特定类型及其子类型作为參数. 以下就举一个方法限定接收參数的类型的样例来说明怎样限定类型变量. 首先有几个简单的辅助类: ...

  5. POJ 3580(SuperMemo-Splay区间加)[template:Splay V2]

    SuperMemo Time Limit: 5000MS   Memory Limit: 65536K Total Submissions: 11384   Accepted: 3572 Case T ...

  6. 【浅墨Unity3D Shader编程】之三 光之城堡篇:子着色器、通道与标签的写法 &amp; 纹理混合

    本系列文章由@浅墨_毛星云 出品,转载请注明出处.   文章链接:http://hpw123.net/a/C__/kongzhitaichengxu/2014/1117/120.html 作者:毛星云 ...

  7. caffe搭建--WINDOWS+VS2013下生成caffe并进行cifar10分类测试

    http://blog.csdn.net/naaaa/article/details/52118437 标签: windowsvs2013caffecifar10 2016-08-04 15:33 1 ...

  8. Java爬虫快速开发工具uncs的部署攻略

    写在前面 uncs是java快速开发爬虫的工具,简单便捷,经过大量版本迭代和生产验证,可以适用大多数网站,推荐使用. 一.基本用法 1.1 开发包获取 目前只能在公司内网maven服务器获取到 < ...

  9. iOS菜鸟学习--怎样避免两个button同一时候响应

    在測试应用时.有时会变态的将两个UIButton同一时候按住来測试.结果就是两个button会同一时候响应,会出现同一时候push两个viewcontroller等非正常情况.为了避免用户误操作造成这 ...

  10. iOS 后台返回json解析出现的null的解决办法

    在后台返回值为Null为空时,我们代码没有判断时,程序就会崩溃.当时一直很疑惑是为啥,后来发现是数据问题,由于服务器的数据库中有些字段为空,然后以Json形式返回给客户端时就会出现这样的数据.当我们通 ...