PS 滤镜—— 径向模糊
这里给出灰度图像的模糊算法,彩色图像只要分别对三个通道做模糊即可。
%%% radiation blur
%%%
clc;
clear all;
close all;
I=imread('4.jpg');
I=double(I);
% Image=I;
Image=0.2989 * I(:,:,1) + 0.5870 * I(:,:,2) + 0.1140 * I(:,:,3);
[row, col]=size(Image);
Image_new(1:row,1:col)=255;
Center_X=(col+1)/2;
Center_Y=(row+1)/2;
alpha=0.85;
for i=1:floor(Center_Y)
for j=floor(Center_X)+1:col
% 第一象限
x1=j-Center_X;
y1=Center_Y-i;
T1=Image(i,j);
% 第三象限
x3=-x1;
y3=-y1;
x_image=floor(Center_X+x3);
y_image=floor(Center_Y-y3);
i3=y_image;
j3=x_image;
T3=Image(y_image,x_image);
% 第二象限
x2=-x1;
y2=y1;
x_image=floor(Center_X+x2);
y_image=floor(Center_Y-y2);
i2=y_image;
j2=x_image;
T2=Image(y_image,x_image);
%第四象限
x4=x1;
y4=-y1;
x_image=floor(Center_X+x4);
y_image=floor(Center_Y-y4);
i4=y_image;
j4=x_image;
T4=Image(y_image,x_image);
k=y1/x1;
x_start=x1*alpha;
y_start=k*x_start;
x_end=x1;
y_end=y1;
x=x_start;
y=y_start;
if(x1>y1)
Num_Pixel=floor(x_end-x_start)+1;
for x=x_start:x_end-1
y0=k*(x+1);
% 第一象限
x1=x+1;
y1=round(y0);
% y=y+1;
x_image=floor(Center_X+x1);
y_image=floor(Center_Y-y1);
T1=T1+Image(y_image,x_image);
% 第三象限
x3=-x1;
y3=-y1;
x_image=floor(Center_X+x3);
y_image=floor(Center_Y-y3);
T3=T3+Image(y_image,x_image);
% 第二象限
x2=-x1;
y2=y1;
x_image=floor(Center_X+x2);
y_image=floor(Center_Y-y2);
T2=T2+Image(y_image,x_image);
% 第四象限
x4=x1;
y4=-y1;
x_image=floor(Center_X+x4);
y_image=floor(Center_Y-y4);
T4=T4+Image(y_image,x_image);
end
else
Num_Pixel=floor(y_end-y_start)+1;
for y=y_start:y_end-1
x0=(y+1)/k;
% 第一象限
x1=floor(x0);
y1=y+1;
x_image=floor(Center_X+x1);
y_image=floor(Center_Y-y1);
T1=T1+Image(y_image,x_image);
% 第三象限
x3=-x1;
y3=-y1;
x_image=floor(Center_X+x3);
y_image=floor(Center_Y-y3);
T3=T3+Image(y_image,x_image);
% 第二象限
x2=-x1;
y2=y1;
x_image=floor(Center_X+x2);
y_image=floor(Center_Y-y2);
T2=T2+Image(y_image,x_image);
% 第四象限
x4=x1;
y4=-y1;
x_image=floor(Center_X+x4);
y_image=floor(Center_Y-y4);
T4=T4+Image(y_image,x_image);
end
end
Image_new(i,j)=T1/Num_Pixel;
Image_new(i2,j2)=T2/Num_Pixel;
Image_new(i3,j3)=T3/Num_Pixel;
Image_new(i4,j4)=T4/Num_Pixel;
end
end
imshow(Image_new/255);
原图
效果图
效果图
PS 滤镜—— 径向模糊的更多相关文章
- Python: PS滤镜--径向模糊
本文用 Python 实现 PS 滤镜中的径向模糊特效,具体的算法原理和效果可以参考之前的博客: http://blog.csdn.net/matrix_space/article/details/3 ...
- OpenCV——PS 滤镜, 浮雕效果
具体的算法原理可以参考: PS 滤镜, 浮雕效果 // define head function #ifndef PS_ALGORITHM_H_INCLUDED #define PS_ALGORITH ...
- OpenCV——PS 滤镜, 曝光过度
算法原理可以参考: PS 滤镜,曝光过度 #ifndef PS_ALGORITHM_H_INCLUDED #define PS_ALGORITHM_H_INCLUDED #include <io ...
- Python: PS 滤镜--水波特效
本文用 Python 实现 PS 滤镜中的 水波特效 import numpy as np from skimage import img_as_float import matplotlib.pyp ...
- Python: PS 滤镜--旋涡特效
本文用Python 实现 PS 滤镜的旋涡特效,具体的算法原理和效果可以参考之前的博客: http://blog.csdn.net/matrix_space/article/details/42215 ...
- Python: PS 滤镜--USM 锐化
本文用 Python 实现 PS 滤镜中的 USM 锐化效果,具体的算法原理和效果可以参考之前的博客: http://blog.csdn.net/matrix_space/article/detail ...
- Python: PS 滤镜--素描
本文用 Python 实现 PS 滤镜中的素描特效,具体的算法原理和效果可以参考之前的博客: http://blog.csdn.net/matrix_space/article/details/386 ...
- Python: PS 滤镜--表面模糊
本文用 Python 实现 PS 滤镜中的表面模糊,具体的算法原理和效果可以参考之前的博客: http://blog.csdn.net/matrix_space/article/details/528 ...
- Python: PS 滤镜--旋转模糊
本文用 Python 实现 PS 滤镜中的旋转模糊,具体的算法原理和效果可以参考之前的博客: http://blog.csdn.net/matrix_space/article/details/392 ...
随机推荐
- Android Firebase 服务简介
Firebase初步了解 什么事Firebase?Firebase成立于2011年,在被Google收购之前,Firebase是一个协助开发者快速构建App,能够提供行动应用专用开发平台及SDK的一款 ...
- android viewpager切换到最后一页时,跳转至其他activity
许许多多的qpp,在启动时会显示一些帮助页或者产品介绍什么的,通常滑动到最后一页时会有一个开始体验的按钮,用来跳转到app的主activity上,但是如果没有? 可以通过如下方法实现: 1.为View ...
- Dynamics CRM2016 New features in Microsoft Dynamics CRM Online 2015 Update 1 are now available
很多人看过Dynamics CRM Online 2015 Update 1后,被它新的一个界面风格所吸引,还有它的很多新增功能,虽然官网放出了些补丁,但最重要的Server补丁一直没出,包括我在内很 ...
- java中的interface接口
接口:java接口是一些方法表征的集合,但是却不会在接口里实现具体的方法. java接口的特点如下: 1.java接口不能被实例化 2.java接口中声明的成员自动被设置为public,所以不存在pr ...
- Github Pages 搭建HEXO主题个人博客
跌跌撞撞,总算是建立起来了.回首走过的这么多坑,也真的是蛮不容易的.那么就写点东西,记录我是怎么搭建的吧. 准备工作 安装Node.js: 用于生成静态页面,我们需要到官网上去下载即可.http:// ...
- iOS下JS与原生OC互相调用(总结)
这是去年总结的一篇文章,也一并先放到这个目录下好了. iOS开发免不了要与UIWebView打交道,然后就要涉及到JS与原生OC交互,今天总结一下JS与原生OC交互的两种方式. JS调用原生OC篇 方 ...
- (NO.00004)iOS实现打砖块游戏(八):游戏中小球与砖块的碰撞
大熊猫猪·侯佩原创或翻译作品.欢迎转载,转载请注明出处. 如果觉得写的不好请告诉我,如果觉得不错请多多支持点赞.谢谢! hopy ;) 现在回到GameScene.m中,我们所有的碰撞处理就放在该类中 ...
- 【一天一道LeetCode】#292. Nim Game
一天一道LeetCode 从今天开始,调整规律,不按顺序做,从easy开始! 本系列文章已全部上传至我的github,地址:ZeeCoder's Github 欢迎大家关注我的新浪微博,我的新浪微博 ...
- iOS开发之六:常用控件--UIImageView的使用
UIImageView是我们做iOS开发用的非常多的一个控件,IOS中的各种图片,包括头像,有的背景图片等基本都要用到这个控件. 1.常用的属性以及方法 <span style="fo ...
- [C++学习历程]基础部分 C++中的指针数组和结构
作者:苏生米沿 本文地址:http://blog.csdn.net/sushengmiyan/article/details/19938177 一.指针 对学习C++来说,指针是一项重要内容,以前,教 ...