python - ImageMagick 到魔杖 : problem with sparse-color Barycentric

标签 python wand

我不知道如何将 ImageMagick 转换为 Wand 指令。

convert beijing_contrast.jpg \
          -sparse-color Barycentric '0,0 black 0,%h white' \
          -function polynomial 4,-4,1   beijing_blurmap.jpg

img.function('polynomial', [4, -4, 1]) 似乎没问题,但是对于 -sparse-color 指令...

最佳答案

在 Wand 中,可以通过传递 dict 映射来调用方法 Image.spase_color()

尽管您无法使用百分比转义 (%h) 参数。

with Image(filename='beijing_contrast.jpg') as img:
    points = {'black': (0, 0), 'white': (0, img.height)}
    img.sparse_color('barycentric', points)
    img.function('polynomial', [4, -4, 1])
    img.save(filename='beijing_blurmap.jpg')

关于python - ImageMagick 到魔杖 : problem with sparse-color Barycentric,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57142296/

相关文章:

python - Decimal(str(my_float)) 似乎比 Decimal(my_float) 好,这是怎么回事?

Python缩进之谜

xml - 在终端中编辑 XML 文件

python-3.x - 魔杖策略错误 : error/constitute. c/ReadImage/412

python - 如何在 python 中使用 wand 创建图像

python - 如何使用 Python 随机提取 FASTA 序列?

python - 确保 Set Python 迭代的随机顺序

python - 如何在 python 中构建网络流?

python - 使用 python wand 对图像进行灰度化