PS 滤镜——(扭曲)逆球面化 (凹陷效果)

来源:互联网 发布:数据安全资质 编辑:程序博客网 时间:2024/04/28 08:18
%%% Inverse_Spherize%%% 逆球面化clc;clear all;close all;addpath('E:\PhotoShop Algortihm\Image Processing\PS Algorithm');I=imread('4.jpg');Image=double(I);[row, col,layer]=size(Image);R=floor(min(row, col)/2);K=pi/2;Image_new=Image;alpha=1;for i=1:row    for j=1:col        y0=(row+1)/2-i;        x0=j-(col+1)/2;        Dis=x0.^2+y0.^2;        radius0=sqrt(Dis);        if(Dis<R*R)            if(x0~=0)                beta=atan(y0/x0);                if(x0<0)                    beta=beta+pi;                end            else                beta=pi/2;            end            theta=radius0/R*K;            radius=R*sin(theta);            radius=(radius-radius0)*alpha+radius0;            x=radius*cos(beta);            y=radius*sin(beta);            x=col/2+x;            y=row/2-y;            if(x>1 && x<col && y>1 && y<row)                x1=floor(x);                y1=floor(y);                p=x-x1;                q=y-y1;                for k=1:layer                Image_new(i,j,k)=(1-p)*(1-q)*Image(y1,x1,k)+p*(1-q)*Image(y1,x1+1,k)...                             +q*(1-p)*Image(y1+1,x1,k)+p*q*Image(y1+1,x1+1,k);                end            end        end    endendimshow(Image_new/255);


原图 


效果图


0 0
原创粉丝点击