// 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. linux查看系统CPU,内存,硬盘使用情况

    top查看CPU,内存使用情况 free查看硬盘使用情况

  2. BEGINNING SHAREPOINT&#174; 2013 DEVELOPMENT 第12章节--SP 2013中远程Event Receivers 远程Event Receivers App级别生命周期

    BEGINNING SHAREPOINT® 2013 DEVELOPMENT 第12章节--SP 2013中远程Event Receivers  远程Event Receivers App级别生命周期 ...

  3. 【转载】GitHub中国区前100名到底是什么样的人

    转载了这篇文章: http://www.jianshu.com/p/d29cba7934c9 这篇文章真是太牛了!转载过来涨涨见识,同时好好励志一把.还有,ruanyifeng怎么长那样... 哈 另 ...

  4. iOS经常使用设计模式——单例模式

    第一部分: 创建一个单例对象 单例的应用场景: 单例模式用于当一个类仅仅能有一个实例的时候. 通常情况下这个"单例"代表的是某一个物理设备比方打印机,或是某种不能够有多个实例同一时 ...

  5. jQeury入门:遍历

    一旦用jQuery创建一个初始的包装集.你就能深度遍历刚刚选择的包装集. 遍历能够被分为三个基础元件:父级.子级,同级.jQuery为全部这些元件提供丰富易用的方法.注意每个方法都能轻易的传递给字符串 ...

  6. 改进后的向量空间模型(VSM)

    我们採用更加形式化的定义,并採用稍大一些的样例来展示怎样使用基于数据集频率的权重.相应于一个给定的词项,其权重使用IDF(逆文档频率)来计算. 为了给每篇文档建立一个相应的向量,能够考虑例如以下定义. ...

  7. react 监听 移动端 手机键盘 enter 事件

    处理方法: (1)html书写 form标签中去掉action参数,定义onSubmit方法,如下所示: /** * 搜索框 组件 */ import React,{PureComponent} fr ...

  8. 小谈Vim打开文件开头的&lt;feff&gt;

    在本地Windows机上开发的PHP程序上传到linuxserver上后,通过浏览器訪问对应接口.发现返回的数据前多了一个莫名的字符'-',甚为不解.之后通过网络抓包的方式,查看到接口返回数据前多了 ...

  9. mysql服务停止

    mysql链接方式分为 tcp链接和 sock链接,   你刚才看到服务停止了还能链接 那种会员是 sock的会话模式   所以需要把所有链接mysql的进程结束掉,才能启动起来的   windows ...

  10. Anacoda 介绍、安装、环境切换

    官网下载 概述 很多学习python的初学者甚至学了有一段时间的人接触到anaconda或者其他虚拟环境工具时觉得无从下手, 其主要原因就是不明白这些工具究竟有什么用, 是用来做什么的, 为什么要这么 ...