📜  Python中的魔杖重映射()函数

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

Python中的魔杖重映射()函数

重映射效果将所有像素替换为在相似性参考图像中找到的最接近的匹配像素。 remap()重建与给定亲和图像颜色最接近的图像调色板。

输入图像:

示例 1:

# Import Image from wand.image module
from wand.image import Image
  
with Image(filename ="koala.jpeg") as left:
    with left.clone() as right:
        with Image(width = 100, height = 1, pseudo ="plasma:") as affinity:
  
            # remap image using remap() function
            right.remap(affinity)
        left.extent(width = left.width * 2)
  
        # adding remaped image with original image
        left.composite(right, top = 0, left = right.width)
    left.save(filename ="remapk.jpeg")

输出:

输入图像:

示例 2:

# Import Image from wand.image module
from wand.image import Image
  
with Image(filename ="road.jpeg") as left:
    with left.clone() as right:
        with Image(width = 100, height = 1, pseudo ="plasma:") as affinity:
  
            # remap image using remap() function
            right.remap(affinity)
        left.extent(width = left.width * 2)
  
        # adding remaped image with original image
        left.composite(right, top = 0, left = right.width)
    left.save(filename ="roadr.jpeg")

输出: