// 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 /*
This program will generate
spin blur effect */ #include "PS_Algorithm.h"
#include <time.h> using namespace std;
using namespace cv; int main()
{
string Img_name("4.jpg");
Mat Img_in;
Img_in=imread(Img_name);
Show_Image(Img_in, Img_name); Mat Img_out(Img_in.size(), CV_32FC3);
Img_in.convertTo(Img_out, CV_32FC3); int width=Img_in.cols;
int height=Img_in.rows; int n_point=1; float angle=30; float w=angle*3.1415926/180;
float w_2=w*w; int Num=3;
int Num2=Num*Num; Point Center(width/2, height/2);
float t1, t2, t3;
int x1, y1;
int x2, y2;
int new_x, new_y; for (int y=0; y<height; y++)
{
for (int x=0; x<width; x++)
{
n_point=1;
x1=x-Center.x;
y1=Center.y-y; t1=Img_in.at<Vec3b>(y, x)[0];
t2=Img_in.at<Vec3b>(y, x)[1];
t3=Img_in.at<Vec3b>(y, x)[2]; x2=x1; y2=y1; for (int mm=0; mm<Num; mm++)
{
x1=x2;
y1=y2; // anticlockwise
x2=x1-w*y1/Num-w_2*x1/Num2;
y2=y1+w*x1/Num-w_2*y1/Num2; // clockwise
//x2=x1+w*y1/Num-w_2*x1/Num2;
//y2=y1-w*x1/Num-w_2*y1/Num2; new_x=x2+Center.x;
new_y=Center.y-y2; if (new_x>0 && new_x<width-1 && new_y>0 && new_y<height-1)
{
t1=t1+Img_in.at<Vec3b>(new_y, new_x)[0];
t2=t2+Img_in.at<Vec3b>(new_y, new_x)[1];
t3=t3+Img_in.at<Vec3b>(new_y, new_x)[2];
n_point++;
} } Img_out.at<Vec3f>(y, x)[0]=t1/n_point;
Img_out.at<Vec3f>(y, x)[1]=t2/n_point;
Img_out.at<Vec3f>(y, x)[2]=t3/n_point; }
} Img_out=Img_out/255.0;
Show_Image(Img_out, "out"); imwrite("Out.jpg", Img_out*255); 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); }

原图

效果图

OpenCV——旋转模糊 (二)的更多相关文章

  1. OpenCV——旋转模糊

    参考来源: 学习OpenCV:滤镜系列(5)--径向模糊:缩放&旋转 // define head function #ifndef PS_ALGORITHM_H_INCLUDED #defi ...

  2. OpenCV探索之路(二十四)图像拼接和图像融合技术

    图像拼接在实际的应用场景很广,比如无人机航拍,遥感图像等等,图像拼接是进一步做图像理解基础步骤,拼接效果的好坏直接影响接下来的工作,所以一个好的图像拼接算法非常重要. 再举一个身边的例子吧,你用你的手 ...

  3. PS 滤镜——旋转模糊

    这里给出灰度图像的模糊算法,彩色图像只要分别对三个通道做模糊即可. %%  spin blur % 旋转模糊 clc; clear all; close all; I=imread('4.jpg'); ...

  4. opencv 增强现实(二):特征点匹配

    import cv2 as cv import numpy as np # def draw_keypoints(img, keypoints): # for kp in keypoints: # x ...

  5. 图片人脸检测——OpenCV版(二)

    图片人脸检测 人脸检测使用到的技术是OpenCV,上一节已经介绍了OpenCV的环境安装,点击查看. 往期目录 视频人脸检测——Dlib版(六)OpenCV添加中文(五)图片人脸检测——Dlib版(四 ...

  6. SpinBlur - 旋转模糊

    [SpinBlur - 旋转模糊] Using the Spin Blur effect, you can rotate and blur the image around one or more p ...

  7. Python: PS 滤镜--旋转模糊

    本文用 Python 实现 PS 滤镜中的旋转模糊,具体的算法原理和效果可以参考之前的博客: http://blog.csdn.net/matrix_space/article/details/392 ...

  8. opencv 简单模糊和高斯模糊 cvSmooth

    cv::Mat 是C++版OpenCV的新结构. cvSmooth() 是老版 C API. 没有把C接口与C + + 结合. 建议你们也可以花一些时间看一下介绍. 同样,你如果查看opencv/mo ...

  9. OpenCV探索之路(二十三):特征检测和特征匹配方法汇总

    一幅图像中总存在着其独特的像素点,这些点我们可以认为就是这幅图像的特征,成为特征点.计算机视觉领域中的很重要的图像特征匹配就是一特征点为基础而进行的,所以,如何定义和找出一幅图像中的特征点就非常重要. ...

随机推荐

  1. Android中打包JAR时获取资源ID的方法

    前言:在打包android源码的时,有的时候源码中包含了资源文件,但是jar包中不包含,所以会异常,解决的方案就是不用系统的提供的id名,而是直接 获取id,如反射. 1.系统提供的方法: /** * ...

  2. 中国程序员如何去 Facebook 工作?

    1.在Facebook,可以选择哪里工作? Facebook 在内地确实没有 Office ,但可以在https://www.facebook.com/careers/?ref=pf#location ...

  3. Linux 服务器配置JDK

    1. 查看java版本 [root@plttestap5 ~]# java -versionjava version "1.8.0_121"Java(TM) SE Runtime ...

  4. python的进程和线程

    关于进程: An executing instance of a program is called a process.程序的执行实例称为进程. Each process provides the ...

  5. zoj 3716 Ribbon Gymnastics【神奇的计算几何】

    题目:http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemCode=3716 来源:http://acm.hust.edu.cn/vjudg ...

  6. go语言之并发编程一

    Go语言最大的优势就在于并发编程.Go语言的关键字go就是开启并发编程也就是goroutine的唯一途径.一条go语句以为着一个函数或方法的并发执行.Go语句是由go关键字和表达式组成.比如下面的这种 ...

  7. ABAP 发邮件(三)

    [转自http://blog.sina.com.cn/s/blog_7c7b16000101bnxk.html]SAP ABAP 发邮件方法三(OO) *&------------------ ...

  8. pandas.resample()

    http://www.cnblogs.com/hhh5460/p/5596340.html resample与groupby的区别:resample:在给定的时间单位内重取样groupby:对给定的数 ...

  9. 《程序员代码面试指南》第二章 链表问题 删除中间节点和a/b处节点

    题目 例如 1-2-3-4 删除2,1-2-3-4-5 删除3 例如 a=1,b =2 java代码 /** * @Description:删除中间节点和a/b处节点 * @Author: lizho ...

  10. BootStrap实现左侧或右侧竖式tab选项卡

    BootStrap实现左侧或右侧竖式tab选项卡 代码如下: <div style="height: 100px;"> <div class="col- ...