當前位置: 首頁>>代碼示例 >>用法及示例精選 >>正文


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。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。