国产片侵犯亲女视频播放_亚洲精品二区_在线免费国产视频_欧美精品一区二区三区在线_少妇久久久_在线观看av不卡

腳本之家,腳本語言編程技術及教程分享平臺!
分類導航

Python|VBS|Ruby|Lua|perl|VBA|Golang|PowerShell|Erlang|autoit|Dos|bat|

服務器之家 - 腳本之家 - Python - Python實現PS濾鏡特效之扇形變換效果示例

Python實現PS濾鏡特效之扇形變換效果示例

2021-01-09 00:21Matrix_11 Python

這篇文章主要介紹了Python實現PS濾鏡特效之扇形變換效果,結合實例形式分析了Python實現PS濾鏡扇形變換效果的原理與相關操作技巧,需要的朋友可以參考下

本文實例講述了Python實現PS濾鏡特效之扇形變換效果。分享給大家供大家參考,具體如下:

這里用 Python 實現 PS 濾鏡中的一種幾何變換特效,稱為扇形變換,將圖像扭曲成一個扇形,具體的算法原理和效果圖可以參考附錄說明

?
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
import numpy as np
from skimage import img_as_float
import matplotlib.pyplot as plt
from skimage import io
import math
import numpy.matlib
file_name2='D:/Visual Effects/PS Algorithm/4.jpg'
img=io.imread(file_name2)
img = img_as_float(img)
# control the radius of the inner circle
radius = 150
# control the distance between the inner circle and outer circle
high = 200
angle = 0
spreadAngle = math.pi
# set the center of the circle, proportion of the image size
centerX = 0.5
centerY = 1.0
row, col, channel = img.shape
icenterX = col * centerX
icenterY = row * centerY
img_out = img * 0
xx = np.arange (col)
yy = np.arange (row)
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 - icenterX
yy_dif = y_mask - icenterY
theta = np.arctan2(-yy_dif, -xx_dif+0.0001)
r = np.sqrt(xx_dif*xx_dif + yy_dif * yy_dif)
theta = np.mod(theta, 2 * math.pi)
x1_mask = col * theta/(spreadAngle+0.00001)
y1_mask = row * (1-(r-radius)/(high+0.00001))
'''
mask = x1_mask < 0
x1_mask = x1_mask * (1 - mask)
mask = x1_mask > (col - 1)
x1_mask = x1_mask * (1 - mask) + (x1_mask * 0 + col -2) * mask
mask = y1_mask < 0
y1_mask = y1_mask * (1 - mask)
mask = y1_mask > (row -1)
y1_mask = y1_mask * (1 - mask) + (y1_mask * 0 + row -2) * mask
'''
int_x = np.floor (x1_mask)
int_x = int_x.astype(int)
int_y = np.floor (y1_mask)
int_y = int_y.astype(int)
for ii in range(row):
  for jj in range (col):
    new_xx = int_x [ii, jj]
    new_yy = int_y [ii, jj]
    if x1_mask [ii, jj] < 0 or x1_mask [ii, jj] > col -1 :
      continue
    if y1_mask [ii, jj] < 0 or y1_mask [ii, jj] > row -1 :
      continue
    img_out[ii, jj, :] = img[new_yy, new_xx, :]
plt.figure (1)
plt.title('www.zyiz.net')
plt.imshow (img)
plt.axis('off')
plt.figure (2)
plt.title('www.zyiz.net')
plt.imshow (img_out)
plt.axis('off')
plt.show()

附錄:PS 濾鏡— —扇形warp

?
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
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

本例Python運行效果:

原圖

Python實現PS濾鏡特效之扇形變換效果示例

效果圖

Python實現PS濾鏡特效之扇形變換效果示例

希望本文所述對大家Python程序設計有所幫助。

原文鏈接:http://blog.csdn.net/matrix_space/article/details/72286194

延伸 · 閱讀

精彩推薦
Weibo Article 1 Weibo Article 2 Weibo Article 3 Weibo Article 4 Weibo Article 5 Weibo Article 6 Weibo Article 7 Weibo Article 8 Weibo Article 9 Weibo Article 10 Weibo Article 11 Weibo Article 12 Weibo Article 13 Weibo Article 14 Weibo Article 15 Weibo Article 16 Weibo Article 17 Weibo Article 18 Weibo Article 19 Weibo Article 20 Weibo Article 21 Weibo Article 22 Weibo Article 23 Weibo Article 24 Weibo Article 25 Weibo Article 26 Weibo Article 27 Weibo Article 28 Weibo Article 29 Weibo Article 30 Weibo Article 31 Weibo Article 32 Weibo Article 33 Weibo Article 34 Weibo Article 35 Weibo Article 36 Weibo Article 37 Weibo Article 38 Weibo Article 39 Weibo Article 40
主站蜘蛛池模板: 国产综合在线播放 | 中文字幕一区三级久久日本 | 亚洲激情一区 | 日韩一级大片 | 2018自拍偷拍 | 91羞羞网站| 日韩欧美的一区二区 | 亚洲毛片| 一级a毛片 | 免费观看黄色12片一级视频 | 真实国产露脸乱 | 日本一区二区三区在线视频 | 国产高清久久久 | 超碰精品在线 | 激情五月综合网 | 亚洲精品一区二区三区在线观看 | 一区二区三区高清不卡 | 欧美视频免费在线 | 国产一区二区三区在线 | 成人a在线| 成人午夜天堂 | 国产精品欧美久久久 | 欧美怡红院视频一区二区三区 | 欧美精品三区 | 精品亚洲成a人在线观看 | 久久99国产精一区二区三区 | eeuss国产一区二区三区四区 | 黄色在线观看视频网站 | 东南亚一级毛片 | 99精品久久 | 综合久久99 | 久久成人一区 | 国产精品久久久久久亚洲调教 | 亚洲婷婷免费 | 日韩欧美三级在线观看 | 国产啊v在线观看 | 久草免费在线视频 | 欧美a级成人淫片免费看 | 久久在线看 | 国产精品一区二区不卡 | 欧美一级片在线 |