魔杖 unsharp_mask()函数- Python
unsharp_mask()类似于Python Wand 中的普通sharpen() 方法,但它可以控制过滤器和原始(数量参数)之间的混合,以及阈值。当数量值大于 1.0 时,如果应用了锐化过滤器,则如果值小于 1.0,则更少。阈值超过 0.0 会降低锐化。
Syntax :
Python3
Python3
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 sharp image using unsharp_sharpen() function.
img.unsharp_mask(radius = 8,
sigma = 4,
amount = 1,
threshold = 0.5)
img.save(filename ="unsharpmaskkoala.jpeg")
Parameters :
Parameter Input Type Description radius numbers.Real Size of gaussian aperture. sigma numbers.Real the standard deviation of the Gaussian, in pixels. amount numbers.Real The percentage of the difference between the original and the blur image that is added back into the original threshold numbers.Real The threshold in pixels needed to apply the difference amount.
源图像:
示例 1:
Python3
wand.image.unsharp_mask(radius, sigma, amount, threshold)
输出:
示例 2:将阈值增加到 0.5 并减小半径和 sigma。
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 sharp image using unsharp_sharpen() function.
img.unsharp_mask(radius = 10,
sigma = 4,
amount = 1,
threshold = 0)
img.save(filename ="unsharpmaskkoala.jpeg")
输出: