码迷,mamicode.com
首页 > 其他好文 > 详细

PS 滤镜— — sparkle 效果

时间:2015-11-11 16:37:14      阅读:298      评论:0      收藏:0      [点我收藏+]

标签:photoshop   算法   

    clc;
    clear all;
    close all;

    addpath(‘E:\PhotoShop Algortihm\Image Processing\PS Algorithm‘);

    I=imread(‘4.jpg‘);
    Image=double(I)/255;

    [height, width, depth]=size(Image);

    rays = 25;
    radius = 25;   
    amount = 25;     % 1-100
    color = [1.0, 1.0, 1.0];   % 0-1
    randomness = 25;
    centreX=width/2.0;
    centreY=height/2.0;
    % % seed = 371;
    rayLengths=radius+randomness / 100.0 * radius * rand(1,rays);

    Img_new=Image;

    for ii=1:height
        for jj=1:width

            dx = jj-centreX;
            dy = ii-centreY;
            distance=sqrt(dx*dx+dy*dy);
            angle = atan2(dy, dx);
            d = (angle+pi) / (2*pi) * rays;
            f=d-floor(d);
            len_1=rayLengths(mod(floor(d), rays)+1);
            len_2=rayLengths(mod(floor(d)+1, rays)+1);
            length = lerp(f, len_1,  len_2);
            g = length*length / (distance+0.0001);
            g = g.^((100-amount) / 50.0);
            f =f - 0.5;
    % %         f = 1-f*f;
            f =f * cos(g);
    % %         f =f * sin(g);


            f=min(max(0,f),1);

            r=Image(ii, jj, 1);
            g=Image(ii, jj, 2);
            b=Image(ii, jj, 3);

            Img_new(ii, jj, 1)=lerp(f, r, color(1));
            Img_new(ii, jj, 2)=lerp(f, g, color(2));
            Img_new(ii, jj, 3)=lerp(f, b, color(3));


        end
    end

    imshow(Img_new);
    imwrite(Img_new, ‘out.jpg‘);

参考来源:http://www.jhlabs.com/index.html

原图:

技术分享

效果图:

技术分享

技术分享

版权声明:本文为博主原创文章,未经博主允许不得转载。

PS 滤镜— — sparkle 效果

标签:photoshop   算法   

原文地址:http://blog.csdn.net/matrix_space/article/details/46906961

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!