Wand – Python中的 sketch()函数
Sketch是Python中 Wand 库中的另一种艺术特效。 sketch()函数在输出中生成铅笔素描图像。为获得最佳效果,半径值应大于 sigma。
Syntax :
Python3
Python3
Python3
# import display() to show final image
from wand.display import display
# import Image from wand.image module
from wand.image import Image
# read file using Image function
with Image(filename ="koala.jpeg") as img:
# transform to grayscale image
img.transform_colorspace("gray")
# perform adaptive blur effect using adaptive_blur() function
img.sketch(0.5, 0.0, 98.0)
# save final image
img.save(filename ="rb_koala.jpeg")
# display final image
display(img)
Parameter :
Parameter Input Type Description radius numbers.Real Size of Gaussian aperture. sigma numbers.Real standard deviation of the Gaussian operator. angle numbers.Real direction of blur.
源图像:
示例 #1:
Python3
wand.image.sketch( radius, sigma, angle)
# radius should always be greater than sigma(standard deviation)
输出 :
示例#2:为了获得最佳结果,将图像转换为灰度图像
Python3
# import display() to show final image
from wand.display import display
# import Image from wand.image module
from wand.image import Image
# read file using Image function
with Image(filename ="koala.jpeg") as img:
# perform adaptive blur effect using adaptive_blur() function
img.sketch(0.5, 0.0, 98.0)
# save final image
img.save(filename ="rb_koala.jpeg")
# display final image
display(img)
输出 :