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 ...
随机推荐
- Leanote 二进制版详细安装教程 Windows
https://github.com/leanote/leanote/wiki 本教程适合 Windows 用户的二进制版安装. Windows 用户的源码版安装,参见这里. Mac, Linux 用 ...
- 安装 - LNMP一键安装包
https://lnmp.org/ 系统需求: CentOS/RHEL/Fedora/Debian/Ubuntu/Raspbian Linux系统 需要5GB以上硬盘剩余空间 需要128MB以上内存( ...
- Oracle-31-对视图DML操作
一.对视图进行DML操作 1.创建一个视图v_person create or replace noforceview v_person as select *from person where id ...
- 新建 .NET Core 控制台项目 C# 数组深拷贝
新建 .NET Core 控制台项目 1. 安装 .NET Core SDK 1.0 参考微软官方网站 https://www.microsoft.com/net/download/windows 2 ...
- 【软件创意】智能Goals (android)
智能Goals 软件创意核心思想:实现你的愿望. 功能概要:帮助记录奋斗了的历程.实现你的愿望.可以是跑步减肥,每天阅读,交际,存钱买房.满足各种记录需要,目标可以是完成多长时间,可以用计时器:可以 ...
- Laravel建站01--开发环境部署
内容导航 安装git 安装composer 安装Laravel 既然是开发环境,就需要源代码管理.这里使用git来管理. 一:部署开发环境之前安装git 在 Linux 上安装git 如果你想在 Li ...
- 误用了 react-scripts eject 命令
react 小白编程 由于使用 create-react-app 脚手架构建项目的时候,会给几个命令用 其中一个命令吸引了我的注意力 yarn eject,因为构建完成后特别提示说“你不会想要用到这 ...
- 关于erlang中的timer:tc/3
timer:tc/3对于统计函数运行时间是个很不错的函数, 截图timer:tc/1,tc/2,tc/3的API: 拿斐波那契数列入手做个讲解: -module(fib). -export([fib/ ...
- MySQL 存储过程 (3)
以下介绍下像数据库循环插入数据操作 第一步:建立存储过程用到的信息表
- 2018.11.22-day24 面向对象-继承
1.归一化设计 2.抽象类 3.钻石继承 4.C3算法 5.新式类中的super