gpt4 book ai didi

Python实现PS滤镜碎片特效功能示例

转载 作者:qq735679552 更新时间:2022-09-28 22:32:09 25 4
gpt4 key购买 nike

CFSDN坚持开源创造价值,我们致力于搭建一个资源共享平台,让每一个IT人在这里找到属于你的精彩世界.

这篇CFSDN的博客文章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
from skimage import img_as_float
import matplotlib.pyplot as plt
from skimage import io
file_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 = 7
row, col, channel = img.shape
img_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.0
plt.figure( 1 )
plt.imshow(img)
plt.axis( 'off' );
plt.figure( 2 )
plt.imshow(img_out)
plt.axis( 'off' );

附:PS 滤镜算法原理——碎片效果 。

?
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
% % % 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);

原图:

Python实现PS滤镜碎片特效功能示例

效果图:

Python实现PS滤镜碎片特效功能示例

希望本文所述对大家Python程序设计有所帮助.

原文链接:http://blog.csdn.net/matrix_space/article/details/72303014 。

最后此篇关于Python实现PS滤镜碎片特效功能示例的文章就讲到这里了,如果你想了解更多关于Python实现PS滤镜碎片特效功能示例的内容请搜索CFSDN的文章或继续浏览相关文章,希望大家以后支持我的博客! 。

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com