📜  Python – Wand 中的 evaluate()函数

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

Python – Wand 中的 evaluate()函数

evaluate()函数中,可以通过应用算术、关系或逻辑表达式来操作像素通道。

以下是 Wand 中的 EVALUATE_OPS 列表:

ParameterInput TypeDescription
operatorbasestringType of operation to calculate.
valuenumbers.RealNumber to calculate with operator 
 
channelbasestringOptional 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")

输出图像: