CLCClearAll Close all; Addpath (' E:\PhotoShop algortihm\image processing\ps algorithm '); I=imread (' 4.jpg '); I=double (I); image=i/255; Angle = pi/4; CentreX =0.5; Centrey =0.5; radius= $; Amount=0.75;[Height, width, depth]=size(Image); Image_new=image; Icentrex = width * CentreX; Icentrey = height * Centrey;if(RADIUS = =0) radius=min(Icentrex, Icentrey);EndRadius2=radius*radius; forIi=1: Height forjj=1: Width dx = Jj-icentrex; dy = Ii-icentrey; Distance = Dx*dx + dy*dy;if(Distance>radius2 | | distance==0) X=JJ; Y=ii;ElseD =sqrt(DISTANCE/RADIUS2); t =Sin(pi*0.5* d). ^ (-amount); DX =dx* t; Dy =dy* t; E =1-D; A = angle * e * e; s =Sin(a); c =Cos(a); x = Icentrex + c*dx-s*dy; y = Icentrey + s*dx + c*dy;End 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 (ii,jj,:) = (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 EndImshow (image_new) imwrite (Image_new,' out.jpg ');
Reference Source: http://www.jhlabs.com/index.html
Original:
:
Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.
PS Filter--Squeeze effect