Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to realize the Wave effect of PS filter by Python

2025-04-07 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >

Share

Shulou(Shulou.com)05/31 Report--

In this article Xiaobian for you to introduce in detail "Python how to achieve PS filter wave effects", the content is detailed, the steps are clear, the details are handled properly, I hope that this "Python how to achieve PS filter wave special effects" article can help you solve doubts, the following follow the editor's ideas slowly in-depth, together to learn new knowledge.

Using computer programming language to realize the wave effect of police officer filter

Importnumpyasnp

Fromskimageimportimg _ as _ float

Importmatplotlib.pyplotasplt

Fromskimageimportio

Importnumpy.matlib

Importmath

File _ name 2room'd: / VisualEffects/PSalgorithm/4. Jpg'

Img=io.imread (file_name2)

Img=img_as_float (img)

Row,col,channel=img.shape

Img_out=img*1.0

= 70.0

= 30.0

Degrees = 20.0

Center_x= (col-1) / 2.0

Center_y= (row-1) / 2.0

Xx=np.arange (col)

Yy=np.arange (line)

X_mask=numpy.matlib.repmat (xx,row,1)

Y_mask=numpy.matlib.repmat (yy,col,1)

Y_mask=np . Transpose (y_mask)

Xx_dif=x_mask-center_x

Yy_dif=center_y-y_mask

X = degrees * NP. Sin (2 * Mathematics. Pi * YY _ dif/alpha) xx _ dif

Y = degrees * NP. Cos (2 * Mathematics. Pi * xx _ dif/beta) YY _ dif

X_new=x center_x

Y_new=center_y-y

Int_x=np.floor (x_new)

Int_x=int_x.astype (int)

Int_y=np.floor (y_new)

Int_y=int_y.astype (int)

Foriiinrange (row):

Forjjirinrange (col):

New_xx=int_x [ii,jj]

New_yy=int_y [ii,jj]

Ifx_new [ii,jj] 0orx_new [ii,jj] col-1:

Go ahead

Ify_new [ii,jj] 0ory_new [ii,jj] row-1:

Go ahead

Img_out [ii,jj,] = IMG [new _ yy,new_xx,]

Figure (1)

Plt.title ('www.jb51.net')

Plt.imshow (img)

Plt.axis ('off')

Figure (2)

Plt.title ('www.jb51.net')

Plt.imshow (img_out)

Plt.axis ('off')

(appendix: PS filter-Wave wave)

%% wave

% wave effect

Chrominance control center

Clear all

Close all files

Add a path ('e:\ Photoshop algorithm\ image processing\ PSAlgorithm')

I=im read ('4. Jpg')

Image=double (I)

% Image=0.2989*I (: 1) 0.5870 yuan I (: 2) 0.1140yuan I (: 3)

[rows, columns, channels] = size (image)

R=floor (max (row,col) / 2)

Image _ New = Image

Degree = 30% control the degree of distortion

Center _ X = (col 1) / 2

Center _ Y = (first line) / 2

Fori=1:row

Forj=1:col

X0=j-Center _ X

Y0 = Center _ Ymuri

X = degree * sin (2 * pi * y0amp 128) x0

Y = degrees * cos (2 * pi * x0Uniq128) y0

Xerox col/2

Y=row/2-y

If (x1xcolylrow 1)

X1 = floor (x)

Y1 = floor (y)

P=x-x1

Q=y-y1

Image_new (iMaginj,) = 1murp) * (1Muiq) * Image (y1menx1,) p* (1merq) * Image (y1menx11,).

Q * (1murp) * Image (y1 1menx1,) p*q*Image (y11recoverx1,)

End

End

End

Figure, imshow (Image _ new/255); the running effect of this example Python:

Original drawing

Effect picture

Read this, the "Python how to achieve the wave effects of PS filter" article has been introduced, want to master the knowledge of this article still need to practice and use to understand, if you want to know more about the article, welcome to follow the industry information channel.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Internet Technology

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report