PS 滤镜— — sparkle 效果

本文介绍了一种使用Matlab实现图像光晕效果的方法,通过调整光线数量、颜色及强度等参数,对输入图像进行处理,最终得到带有光晕特效的输出图像。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

    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

原图:

这里写图片描述

效果图:

这里写图片描述

这里写图片描述

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值