自定义手绘风

from PIL import Image
im0=np.array(Image.open('D:/26卢英倩/123.jpg').convert('L'))
im1=255-im0
im2=(100/250)*im0+150
im3=255*(im1/255)**2
pil_im=Image.fromarray(np.uint(im1))
pil_im.show()

 

 

# -*- coding: utf-8 -*-
"""
Spyder Editor

This is a temporary script file.
"""

from PIL import Image
import numpy as np
vec_el=np.pi/2.2
vec_az=np.pi/4
depth=10
im=Image.open('C:/Users/history/Desktop/微信图片_20190421201424.jpg').convert('L')
a=np.asarray(im).astype('float')
grad=np.gradient(a)
grad_x,grad_y=grad
grad_x=grad_x*depth/100.
grad_y=grad_y*depth/100.
dx=np.cos(vec_el)*np.cos(vec_az)
dy=np.cos(vec_el)*np.sin(vec_az)
dz=np.sin(vec_el)
A=np.sqrt(grad_x**2+grad_y**2+1.)
uni_x=grad_x/A
uni_y=grad_y/A
uni_z=1./A
a2=255*(dx*uni_x+dy*uni_y+dz*uni_z)
a2=a2.clip(0,255)
im2=Image.fromarray(a2.astype('uint8'))
im2.save('C:/Users/history/Desktop/微信图片_20190421201424.jpg')

posted @ 2019-04-21 21:16  辰光依旧  阅读(255)  评论(0编辑  收藏  举报