Python – Wand 中的 evaluate()函数
在evaluate()函数中,可以通过应用算术、关系或逻辑表达式来操作像素通道。
Syntax :
Parameters :
以下是 Wand 中的 EVALUATE_OPS 列表:
Parameter Input Type Description operator basestring Type of operation to calculate. value numbers.Real Number to calculate with operator
channel basestring Optional channel to apply operation on.
源图像:
代码示例 1:
Python3
wand.image.evaluate(operator, value, channel)
Python3
# Import Image from wand.image module
from wand.image import Image
# Read image using Image function
with Image(filename ="koala.jpeg") as img:
img.evaluate(operator ='rightshift', value = 1, channel ='blue')
img.save(filename ="kl-enhanced.jpeg")
输出图像:
代码示例 2:
Python3
# Import Image from wand.image module
from wand.image import Image
# Read image using Image function
with Image(filename ="koala.jpeg") as img:
img.evaluate(operator ='leftshift', value = 1, channel ='red')
img.save(filename ="kl-enhanced2.jpeg")
输出图像: