The import numpy as np
A=np. Asarray (lmage. Open \
(" D: girlfriend. JPG ") \
Convert (' L ')) \
. Astype (' float ')
The depth=10.
Grad=np. Gradient (a)
Grad_x, grad_y=grad
Grad_x=grad_x * the depth/100.
Grad_y=grad_y * the 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 in sin (vec_az)
Dz=np. Sin (vec_el)
B=255 * (uni_x + dy dx * * uni_y \
+ dz * uni_z)
B=biggest lip (0255)
Im=lmage. Fromarray (b.a stype \
(' uint8))
Im. Save (" D: girlfriend sketch. JPG ")
Print (" successfully saved view ")
CodePudding user response:
D: girlfriend. JPG this is the right path