PS 滤镜— —扇形warp

本文提供了一种基于Photoshop算法的图像处理方法,通过调整参数实现特定效果,并最终保存为输出图片。

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

    clc;
    clear all;
    close all;

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

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

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

    % set the parameters
    radius = 150;  % control the radius of the inner circle
    high = 200;    % control the distance between the inner circle and outer circle
    angle = 0;             
    spreadAngle=pi;    
    centerX = 0.5;  % set the center of the circle, proportion of the image size
    centerY = 1.0;

    icenterX=width*centerX;
    icenterY=height*centerY;

    Image_new=Image*0;

    for i=1:height
        for j=1:width

            dx=j-icenterX;
            dy=i-icenterY;

            theta=atan2(-dy, -dx)+angle;
            r=sqrt(dy*dy+dx*dx);

            theta=mod(theta, 2*pi);

            x=width * theta/(spreadAngle+0.00001);
            y=height * (1-(r-radius)/(high+0.00001));


    % %         if (x<=1)     x=1;  end
    % %         if (x>=width)   x=width-1; end;
    % %         if (y>=height)  y=height-1; end;
    % %         if (y<1)  y=1;     end;
    % %         

            if (x<=1)     continue;  end
            if (x>=width)   continue; end;
            if (y>=height)  continue; end;
            if (y<1)  continue;     end;


            x1=floor(x);
            y1=floor(y);
            p=x-x1;
            q=y-y1;

            Image_new(i,j,:)=(1-p)*(1-q)*Image(y1,x1,:)+p*(1-q)*Image(y1,x1+1,:)...
                +q*(1-p)*Image(y1+1,x1,:)+p*q*Image(y1+1,x1+1,:);


        end

    end
    imshow(Image_new)
    imwrite(Image_new, 'out.jpg');

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

原图

这里写图片描述

效果图

这里写图片描述

评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值