Python实现PS滤镜中的USM锐化效果

Python itxz 5年前 (2020-12-05) 250次浏览 已收录 0个评论

本文用 Python 实现 PS 滤镜中的 USM 锐化效果

import matplotlib.pyplot as plt
from skimage import io
from skimage.filters import gaussian
 
file_name='D:/Visual Effects/PS Algorithm/4.jpg';
img=io.imread(file_name)
 
img = img * 1.0
gauss_out = gaussian(img, sigma=5, multichannel=True)
 
# alpha 0 - 5
alpha = 1.5
img_out = (img - gauss_out) * alpha + img
 
img_out = img_out/255.0
 
# 饱和处理
mask_1 = img_out < 0
mask_2 = img_out > 1
 
img_out = img_out * (1-mask_1)
img_out = img_out * (1-mask_2) + mask_2
 
plt.figure()
plt.imshow(img/255.0)
plt.axis('off')
 
plt.figure(2)
plt.imshow(img_out)
plt.axis('off')
 
plt.show()

实现效果:


IT学者 , 版权所有丨如未注明 , 均为原创丨本网站采用BY-NC-SA协议进行授权
转载请注明原文链接:Python实现PS滤镜中的USM锐化效果
喜欢 (0)

您必须 登录 才能发表评论!