// 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. TensorFlow CNN 測试CIFAR-10数据集

    本系列文章由 @yhl_leo 出品,转载请注明出处. 文章链接: http://blog.csdn.net/yhl_leo/article/details/50738311 1 CIFAR-10 数 ...

  2. 装服务器,测试数据库,简单的maven命令

    [说明]今天总体回顾一下:大概是早上装服务器,下午测试数据库,晚上了解简单的maven命令 一:今日完成 1)在远程服务器的tomcat 设置好管理员的登录账号 2)登录tomcat 的项目管理 查看 ...

  3. 【BZOJ1125】[POI2008]Poc hash+map+SBT

    [BZOJ1125][POI2008]Poc Description n列火车,每条有l节车厢.每节车厢有一种颜色(用小写字母表示).有m次车厢交换操作.求:对于每列火车,在交换车厢的某个时刻,与其颜 ...

  4. 我的Android进阶之旅------>Android疯狂连连看游戏的实现之开发游戏界面(二)

    连连看的游戏界面十分简单,大致可以分为两个区域: 游戏主界面区 控制按钮和数据显示区 1.开发界面布局 本程序使用一个RelativeLayout作为整体的界面布局元素,界面布局上面是一个自定义组件, ...

  5. (转)Javascript模块化编程(二):AMD规范

    这个系列的第一部分介绍了Javascript模块的基本写法,今天介绍如何规范地使用模块. (接上文) 七.模块的规范 先想一想,为什么模块很重要? 因为有了模块,我们就可以更方便地使用别人的代码,想要 ...

  6. IDEA运行后控制台输出乱码

    1.点击 2.点击 3.添加:-Dfile.encoding=UTF-8 . 4.点击OK

  7. angularjs 中的iframe 标签 ng-src 路径 z-index 必须有position

    如果直接写路径到iframe标签里的ng-src中会出现报错: 解决方法: 1.ng里面有个属性是专门用来解决跨域问题的 $sce. 用法: $scope.someUrl = $sce.trustAs ...

  8. R语言数据管理(四):数据导出

    与read.*函数对应,导出函数为write.*函数. 比较常见的为write.csv和write.table. 一般格式: setwd("D:\\") write.table(y ...

  9. 牛客小白月赛1 A 简单题 【数学】

    题目链接 https://www.nowcoder.com/acm/contest/85/A 思路 这个 就是 E 但是 运算的时候 要保证 其精度 AC代码 #include <cstdio& ...

  10. JS中如何获取<Select>中value和text的值

    原文地址:JS中如何获取<Select>中value和text的值 html代码: <select id = "city" onchange="chan ...