国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 編程 > Python > 正文

Python實現(xiàn)PS濾鏡功能之波浪特效示例

2020-02-22 23:00:06
字體:
來源:轉載
供稿:網友

本文實例講述了Python實現(xiàn)PS濾鏡功能之波浪特效。分享給大家供大家參考,具體如下:

這里用 Python 實現(xiàn) PS 濾鏡的波浪特效,具體效果可以參考附錄說明

import numpy as npfrom skimage import img_as_floatimport matplotlib.pyplot as pltfrom skimage import ioimport numpy.matlibimport mathfile_name2='D:/Visual Effects/PS Algorithm/4.jpg'img=io.imread(file_name2)img = img_as_float(img)row, col, channel = img.shapeimg_out = img * 1.0alpha = 70.0beta = 30.0degree = 20.0center_x = (col-1)/2.0center_y = (row-1)/2.0xx = 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 - center_xyy_dif = center_y - y_maskx = degree * np.sin(2 * math.pi * yy_dif / alpha) + xx_dify = degree * np.cos(2 * math.pi * xx_dif / beta) + yy_difx_new = x + center_xy_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)for ii in range(row):  for jj in range (col):    new_xx = int_x [ii, jj]    new_yy = int_y [ii, jj]    if x_new [ii, jj] < 0 or x_new [ii, jj] > col -1 :      continue    if y_new [ii, jj] < 0 or y_new [ii, jj] > row -1 :      continue    img_out[ii, jj, :] = img[new_yy, new_xx, :]plt.figure (1)plt.title('www.jb51.net')plt.imshow (img)plt.axis('off')plt.figure (2)plt.title('www.jb51.net')plt.imshow (img_out)plt.axis('off')plt.show()

附錄:PS 濾鏡——波浪 wave

%%% Wave%%% 波浪效果clc;clear all;close all;addpath('E:/PhotoShop Algortihm/Image Processing/PS Algorithm');I=imread('4.jpg');Image=double(I);% Image=0.2989 * I(:,:,1) + 0.5870 * I(:,:,2) + 0.1140 * I(:,:,3);[row, col,channel]=size(Image);R=floor(max(row, col)/2);Image_new=Image;Degree=30;  % 控制扭曲的程度Center_X=(col+1)/2;Center_Y=(row+1)/2;for i=1:row  for j=1:col    x0=j-Center_X;    y0=Center_Y-i;    x=Degree*sin(2*pi*y0/128)+x0;    y=Degree*cos(2*pi*x0/128)+y0;    x=x+col/2;    y=row/2-y;    if(x>1 && x<col && y<row && y>1)      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  endendfigure, imshow(Image_new/255);

本例Python運行效果:

原圖

效果圖

更多關于Python相關內容感興趣的讀者可查看本站專題:《Python圖片操作技巧總結》、《Python數(shù)據結構與算法教程》、《Python Socket編程技巧總結》、《Python函數(shù)使用技巧總結》、《Python字符串操作技巧匯總》、《Python入門與進階經典教程》及《Python文件與目錄操作技巧匯總》

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

發(fā)表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發(fā)表
主站蜘蛛池模板: 闽清县| 湄潭县| 焦作市| 榆树市| 景东| 都匀市| 克东县| 敦化市| 承德县| 桂阳县| 自治县| 乌鲁木齐市| 三穗县| 保山市| 武陟县| 宣武区| 丰台区| 兰溪市| 安康市| 孟津县| 密云县| 通河县| 栾川县| 云梦县| 镇康县| 荣昌县| 乌兰县| 金平| 桐乡市| 泰和县| 文安县| 乌海市| 海城市| 黎川县| 富川| 佛冈县| 交城县| 昌图县| 浦东新区| 沅江市| 陇南市|