📜  Python中的魔杖函数()函数

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

Python中的魔杖函数()函数

函数()函数类似于评估函数。在函数()函数中,可以通过将多参数函数应用于像素通道来操作像素通道。
以下是 Wand 中的 FUNCTION_TYPES 列表:

  • '不明确的'
  • 'arcsin'
  • 'arctan'
  • '多项式'
  • '正弦曲线'

示例 1:
源图像:

Python3
wand.image.function(function, arguments, channel)


Python3
# Import Image from wand.image module
from wand.image import Image
 
frequency = 3
phase_shift = -90
amplitude = 0.2
bias = 0.7
 
# Read image using Image function
with Image(filename ="koala.jpeg") as img:
    # applying sinusoid FUCTION_TYPE
    img.function('sinusoid', [frequency, phase_shift, amplitude, bias])
    img.save(filename ="kl-functioned.jpeg")


输出 :

示例 2:
源图像:

Python3

# Import Image from wand.image module
from wand.image import Image
 
frequency = 3
phase_shift = -90
amplitude = 0.2
bias = 0.7
 
# Read image using Image function
with Image(filename ="road.jpeg") as img:
    # applying sinusoid FUCTION_TYPE
    img.function('polynomial', [frequency, phase_shift, amplitude, bias])
    img.save(filename ="rd-functioned.jpeg")

输出 :