Python: PS 滤镜--素描

本文用 Python 实现 PS 滤镜中的素描特效,具体的算法原理和效果可以参考之前的博客:

http://blog.csdn.net/matrix_space/article/details/38687427

from skimage import img_as_float
import matplotlib.pyplot as plt
from skimage import io
from skimage.filters._gaussian import gaussian

file_name='D:/Visual Effects/PS Algorithm/4.jpg'
img=io.imread(file_name)

img = img_as_float(img)

I_out = (img[:, :, 0] + img[:, :, 1] + img[:, :, 2]) / 3.0

I_invert = 1.0 - I_out

I_gauss = gaussian(I_invert, sigma=5)

delta = 0.0001
I_dodge = (I_out + delta) / (1 + delta - I_gauss)

th = 0.95
mask = I_dodge > th
max_val = I_dodge.max()
I_dodge = I_dodge * (1-mask) + (th + I_dodge / max_val * (1 - th)) * mask

img_out = I_dodge.copy()

plt.figure(1)
plt.imshow(img)
plt.axis('off')

plt.figure(2)
plt.imshow(img_out, plt.cm.gray)
plt.axis('off')

plt.show()

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值