这里给出灰度图像的模糊算法,彩色图像只要分别对三个通道做模糊即可。

%%%  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 滤镜—— 径向模糊的更多相关文章

  1. Python: PS滤镜--径向模糊

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

  2. OpenCV——PS 滤镜, 浮雕效果

    具体的算法原理可以参考: PS 滤镜, 浮雕效果 // define head function #ifndef PS_ALGORITHM_H_INCLUDED #define PS_ALGORITH ...

  3. OpenCV——PS 滤镜, 曝光过度

    算法原理可以参考: PS 滤镜,曝光过度 #ifndef PS_ALGORITHM_H_INCLUDED #define PS_ALGORITHM_H_INCLUDED #include <io ...

  4. Python: PS 滤镜--水波特效

    本文用 Python 实现 PS 滤镜中的 水波特效 import numpy as np from skimage import img_as_float import matplotlib.pyp ...

  5. Python: PS 滤镜--旋涡特效

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

  6. Python: PS 滤镜--USM 锐化

    本文用 Python 实现 PS 滤镜中的 USM 锐化效果,具体的算法原理和效果可以参考之前的博客: http://blog.csdn.net/matrix_space/article/detail ...

  7. Python: PS 滤镜--素描

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

  8. Python: PS 滤镜--表面模糊

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

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

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

随机推荐

  1. Hibernate通过SQL查询常量时只能返回第一个字符的解决方法

    在Hibernate中如果通过 [java] view plaincopy session.createSQLQuery("select '合计' as name from dual&quo ...

  2. cocos2d-x 3.11 游戏开发环境搭建流程

    cocos2d-x 3.11.1 游戏开发环境搭建流程 1. 准备下面的软件 1) Windows7 64Bit+ VS2013 (VC++) 这个不用多说. 2) cocos2d-x-3.11.1. ...

  3. ExpandableListView仿QQ好友列表

    本例中,对ExpandableListView中的数据进行了封装,分为两个JavaBean,一个为Group类表示组信息,一个Child类表示该组下子列表信息: Group: public class ...

  4. picasso图片缓存框架

    picasso是Square公司开源的一个Android图形缓存库,地址http://square.github.io/picasso/,可以实现图片下载和缓存功能. picasso使用简单,如下 [ ...

  5. 08 ListView 优化

    ListVie的优化 1 固定ListView长宽高 如下图在清单文件中: <ListView android:id="@+id/lv" android:layout_wid ...

  6. [java面试]逻辑推理6 10 18 32 下一个数?编程实现输入任意一个N位置,该数是多少?java实现

    题目: 6 10 18 32 下一个数?编程实现输入任意一个N位置,该数是多少? 10 = 6 + 4         4 18 = 10 + 8        4 + 4  32 = 18 + 14 ...

  7. 【转载】图灵AngularJS入门教程

    摘自图灵的AngularJS入门教程:http://www.ituring.com.cn/article/13471 感觉非常不错,所以推荐到首页一下! (一)Hello World! 开始学习Ang ...

  8. 1057. Stack (30) - 树状数组

    题目如下: Stack is one of the most fundamental data structures, which is based on the principle of Last ...

  9. Cocos2D将v1.0的tileMap游戏转换到v3.4中一例(八)

    大熊猫猪·侯佩原创或翻译作品.欢迎转载,转载请注明出处. 如果觉得写的不好请告诉我,如果觉得不错请多多支持点赞.谢谢! hopy ;) 回到Xcode中,新建一个EndLayer类,继承于CCNode ...

  10. Android进阶(三)android httpClient 支持HTTPS的访问方式

    项目中Android https请求地址遇到了这个异常(无终端认证): javax.net.ssl.SSLPeerUnverifiedException: No peer certificate 是S ...