📜  Python – Wand 中的 shade()函数

📅  最后修改于: 2022-05-13 01:55:10.745000             🧑  作者: Mango

Python – Wand 中的 shade()函数

shade()函数生成 3d 类型的图像或通过从高处模拟光线来创建 3d 效果。 azimuth参数用于控制 X 和 Y 角度, elevation参数用于控制图像的 z 角度。我们还可以通过将gray参数设置为 true 来获得最终的灰度图像。

源图像:

示例 1:

Python3
wand.image.shade(gray, azimuth, elevation);


Python3
# import Image from wand.image module
from wand.image import Image
 
# Read image using Image function
with Image(filename ="koala.jpeg") as img:
 
    # generating shaded image using shade() function.
    img.shade(gray = True,
              azimuth = 286.0,
              elevation = 45.0)
 
    img.save(filename ="shadekoala.jpeg")


输出:

示例2:设置灰色为False,增加方位角和仰角值。

Python3

# import Image from wand.image module
 
from wand.image import Image
 
with Image(filename ="koala.jpeg") as img:
    # generating shaded image using shade() function.
    img.shade(gray = True,
              azimuth = 298.0,
              elevation = 70.0)
 
    img.save(filename ="shadekoala_2.jpeg")

输出: