Opencv— — Circle Filter
// 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的更多相关文章
- Opencv— — kaleidoscope Filter
// define head function #ifndef PS_ALGORITHM_H_INCLUDED #define PS_ALGORITHM_H_INCLUDED #include < ...
- Opencv— — Pinch Filter
// define head function #ifndef PS_ALGORITHM_H_INCLUDED #define PS_ALGORITHM_H_INCLUDED #include < ...
- Opencv— — Twirl Filter
// define head function #ifndef PS_ALGORITHM_H_INCLUDED #define PS_ALGORITHM_H_INCLUDED #include < ...
- [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 ...
- d3js selections深入理解
D3 selections选择DOM元素以便可以对这些dom元素做相应的操作,比如:更改其style,修改其属性,执行data-join操作,或者插入.删除相应elements 比如,如果给定5个ci ...
- [D3] Debug D3 v4 with Dev Tools
Since D3 outputs standard markup, you can use familiar dev tools and inspectors to debug your visual ...
- 【Python】PIL模块
Python自建库,在爬虫等基础应用中更加简单好记,做整理以备自查. 目录 Image模块 open类.Save类.format类.Mode类.convert类.Size类.Info类.new类.Co ...
- 使用CSS实现多种Noise噪点效果
声明:本文涉及图文和模型素材仅用于个人学习.研究和欣赏,请勿二次修改.非法传播.转载.出版.商用.及进行其他获利行为. 背景 在插画中添加噪点肌理可以营造出一种自然的氛围.噪点肌理可以用于塑造阴影.高 ...
- django 操作数据库--orm(object relation mapping)---models
思想 django为使用一种新的方式,即:关系对象映射(Object Relational Mapping,简称ORM). PHP:activerecord Java:Hibernate C#:Ent ...
随机推荐
- 邁向IT專家成功之路的三十則鐵律 鐵律二:IT專家專業之道–專精
在IT技術的領域當中有許多的類別,若要細分那可真是難以一一列舉,但常見的大致有軟體研發工程師.韌體研發工程師.系統分析師.網路工程師.系統工程師.維護工程師.動畫設計師.製圖工程師.以及各類別的專業電 ...
- [反汇编练习] 160个CrackMe之032
[反汇编练习] 160个CrackMe之032. 本系列文章的目的是从一个没有任何经验的新手的角度(其实就是我自己),一步步尝试将160个CrackMe全部破解,如果可以,通过任何方式写出一个类似于注 ...
- 【LeetCode-面试算法经典-Java实现】【002-Add Two Numbers (单链表表示的两个数相加)】
[002-Add Two Numbers (单链表表示的两个数相加)] 原题 You are given two linked lists representing two non-negative ...
- odoo生产物流
odoo生产从raw materials location 自动消耗物料,产成品进入到finish productslocation. 而odoo自动产生的MO[manufacture Order], ...
- nagios插件之登陆SBC监控电话数
运行:sbc_calls_status_new auto_ssh_sbc_10_17.sh | auto_ssh_sbc_11_17.sh vi sbc_calls_status_new.c #inc ...
- mysql:“Access denied for user 'root@IP地址'"
请仔细.再仔细确认你的用户名.密码.IP是否有误! 可悲的我老犯这种低级错误,以为用户没权限访问,唉..
- JS实现搜索模糊匹配
Js代码 <script type="text/javascript"> var websites = [["1231","账上1&q ...
- 07 http内容压缩
一:http内容压缩 思考: Content-Length在之前的学习中,我们知道,代表返回的主体的长度 但此处,为什么返回的主体长度和content-length不一致呢? 原因在于: Conten ...
- 导入EXCEL 时间数据为小数 问题
同事在做将EXCEL导入数据库功能时发现一个奇怪的问题:在EXCEL中,有一列数据明明呈现出时间格式,比如:18:35,但导到数据库中,居然一串长长的小数:0.7743055555555556,我靠, ...
- UIAlertController Changes in iOS 8
本文转载至 http://www.th7.cn/Program/IOS/201409/276000.shtml As part of the theme of iOS 8 to make inte ...