serene-zou
from PIL import Image
import numpy as np
 
a = np.asarray(Image.open(\'C:\\Users\\huanghy\\Desktop\\微信图片_20200425024250.png\').convert("L")).astype("float")
 
depth = 10  #设置深度为10
grad = np.gradient(a)   #对数组a求梯度
 
grad_x, grad_y = grad
grad_x = grad_x*depth/100
grad_y = grad_y*depth/100
A = np.sqrt(grad_x**2 + grad_y**2 + 1.)
uni_x = grad_x/A
uni_y = grad_y/A
uni_z = 1./A
 
vec_el = np.pi/2.2  #θ角度
vec_az = np.pi/4.   #α角度
dx = np.cos(vec_el)*np.cos(vec_az)
dy = np.cos(vec_el)*np.sin(vec_az)
dz = np.sin(vec_el)
 
b = 255*(dx*uni_x + dy*uni_y + dz*uni_z)
b = b.clip(0, 255)
 
im = Image.fromarray(b.astype(\'uint8\'))
im.save("C:\\Users\\huanghy\\Desktop\\微信图片2_20200425024250.png")

分类:

技术点:

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2021-10-10
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-11-17
猜你喜欢
  • 2021-08-28
  • 2021-09-10
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-09-27
  • 2021-11-23
相关资源
相似解决方案