// 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数据适配器(Adapter)优化:使用高效的ViewHolder

    原文链接:http://stackvoid.com/using-adapter-in-efficiency-way/ 在使用Listview或GridView的时候,往往须要自己定义数据适配器.一般都 ...

  2. 自定义circleindicator

    在此申明,并不是自己写的,只是为了方便日后使用 我使用的circleindicator是从大神的gitHub中弄来的, 使用如下: 一.在配置中导入 compile 'me.relex:circlei ...

  3. 1.Python学习---helloworld

    1.首先访问http://www.python.org/download/去下载最新的python版本. 2.安装下载包,一路next. 3.为计算机添加安装目录搭到环境变量,如图把python的安装 ...

  4. nginx学习之简化安装篇(一)

    环境:CentOS 6.5 1. 安装依赖环境 [root@localhost ~]# yum install pcre-devel zlib-devel openssl-devel -y 2. 安装 ...

  5. Inside a super fast CSS engine: Quantum CSS (aka Stylo)

    https://hacks.mozilla.org/2017/08/inside-a-super-fast-css-engine-quantum-css-aka-stylo/?utm_source=d ...

  6. Android笔记之使用ZXing扫描二维码

    ZXing发布版下载地址:https://github.com/zxing/zxing/releases 为了能让官方Demo跑起来,先把ZXing核心部分core复制到自己的工程里 还要把andro ...

  7. POJ3094 Sky Code(莫比乌斯反演)

    POJ3094 Sky Code(莫比乌斯反演) Sky Code 题意 给你\(n\le 10^5\)个数,这些数\(\le 10^5\),问这些这些数组成的互不相同的无序四元组(a,b,c,d)使 ...

  8. vue介绍和简单使用

    Vue是什么? Vue (读音 /vjuː/,类似于 view) 是一套用于构建用户界面的渐进式框架.与其它大型框架不同的是,Vue 被设计为可以自底向上逐层应用.Vue 的核心库只关注视图层,不仅易 ...

  9. FPGA低温不能启动分析

    FPGA低温不能启动分析 现象描写叙述:在给medium板光端机做低温试验时,分别给发送版.接收板断电又一次启动,发现有的板子在-40°能够启动,而有些板子在-20°都不能启动.须要升高温度到0°以上 ...

  10. QT发布的EXE打包压缩成单文件

    Enigma virtual box 是免费的软件虚拟化工具,它可以将多个文件封装到您的应用程序主文件,这样您的软件就可以制作成为单文件的绿色软件. enigma virtual box 支持所有类型 ...