1. 程式人生 > 程式設計 >Python實現PS濾鏡中的USM銳化效果

Python實現PS濾鏡中的USM銳化效果

本文用 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() 

實現效果:

Python實現PS濾鏡中的USM銳化效果

以上就是Python實現PS濾鏡中的USM銳化效果的詳細內容,更多關於python usm銳化的資料請關注我們其它相關文章!