当前位置: 首页>>代码示例 >>用法及示例精选 >>正文


Python Wand remap()用法及代码示例


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

用法: wand.image.remap(affinity, method)

参数:

参数 输入类型 描述
affinity BaseImage 参考图片。
method basestring 抖动方法。参见DITHER_METHODS。默认值为‘no’抖动。

输入图片:

范例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")

输出:




相关用法


注:本文由纯净天空筛选整理自RahulSabharwal大神的英文原创作品 Wand remap() function in Python。非经特殊声明,原始代码版权归原作者所有,本译文未经允许或授权,请勿转载或复制。