CLCClearAll 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); angle=pi/2; CentreX =0.5; Centrey =0.5; radius= $; Icentrex=width*centrex; Icentrey=height*centrey; Radius2=radius*radius; Image_new=image; forIi=1: Height forjj=1: Width Dx=jj-icentrex; Dy=ii-icentrey; Distance2=dx*dx+dy*dy;if(DISTANCE2>RADIUS2) X=jj; Y=ii;ElseDistance=sqrt(DISTANCE2); A = atan2 (dy, dx) + angle * (radius-distance)/radius; x = Icentrex + distance*Cos(a); y = Icentrey + distance*Sin(a);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--twirl Filter