Python實現PS濾鏡片段特效功能樣本,

來源:互聯網
上載者:User

Python實現PS濾鏡片段特效功能樣本,

本文執行個體講述了Python實現PS濾鏡片段特效功能。分享給大家供大家參考,具體如下:

這裡用 Python 實現 PS 濾鏡中的片段特效,這個特效簡單來說就是將映像在 上,下,左,右 四個方向做平移,然後將四個方向的平移的映像疊加起來做平均。具體的與說明可參考附錄說明

from skimage import img_as_floatimport matplotlib.pyplot as pltfrom skimage import iofile_name='D:/Visual Effects/PS Algorithm/4.jpg';img=io.imread(file_name)img = img_as_float(img)img_1 = img.copy()img_2 = img.copy()img_3 = img.copy()img_4 = img.copy()img_out = img.copy()Offset = 7row, col, channel = img.shapeimg_1[:, 0 : col-1-Offset, :] = img[:, Offset:col-1, :]img_2[:, Offset:col-1, :] = img[:, 0 : col-1-Offset, :] img_3[0:row-1-Offset, :, :] = img[Offset:row-1, :, :]img_4[Offset:row-1, :, :] = img[0:row-1-Offset, :, :]img_out = (img_1 + img_2 + img_3 + img_4) / 4.0plt.figure(1)plt.imshow(img)plt.axis('off');plt.figure(2)plt.imshow(img_out)plt.axis('off');

附:PS 濾鏡演算法原理——片段效果

%%% Fragment%%% 對原圖做四個方向的平移,然後對平移的結果取平均%%% 片段效果clc;clear all;Image=imread('4.jpg');Image=double(Image)/255;[row,col,k]=size(Image);Image1=Image;Image2=Image;Image3=Image;Image4=Image;Offset=5;%%% 左移Image1(:,1:col-Offset,:)=Image(:,1+Offset:col,:);%%% 右移Image2(:,1+Offset:col,:)=Image(:,1:col-Offset,:);%%%% 上移Image3(1+Offset:row,:,:)=Image(1:row-Offset,:,:);%%% 下移Image4(1:row-Offset,:,:)=Image(1+Offset:row,:,:);Image=(Image1+Image2+Image3+Image4)/4;figure, imshow(Image);

原圖:

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.