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


Python PIL ImagePath.Path.map()用法及代碼示例

PIL是Python Imaging Library,它為python解釋器提供了圖像編輯函數。 ImagePath模塊用於存儲和處理二維矢量數據。路徑對象可以傳遞給ImageDraw模塊。

ImagePath.Path.map()映射通過函數的路徑。


用法:  ImagePath.Path.map(function)

參數:
arguments-創建列表。
range-分配範圍。

返回:(x0,y0)

   
  
# from PIL importing ImagePath 
from PIL import ImagePath 
  
# creating a list to map 
getbox = list(zip(range(3, 41, 1), range(11, 22, 2))) 
result = ImagePath.Path(getbox) 
  
# using map function 
b = result.map(lambda x, y: (x + 2, y + 2)) 
a = result.tolist() 
print(a)

輸出:

[(5.0, 13.0), (6.0, 15.0), (7.0, 17.0), (8.0, 19.0), (9.0, 21.0), (10.0, 23.0)]

另一個示例:更改參數。

   
# from PIL importing ImagePath 
from PIL import ImagePath 
  
# creating a list to map 
getbox = list(zip(range(3, 41, 1), range(11, 22, 2))) 
result = ImagePath.Path(getbox) 
  
# using map function 
b = result.map(lambda x, y: (x + 12, y + 12)) 
a = result.tolist() 
print(a)

輸出:

[(15.0, 23.0), (16.0, 25.0), (17.0, 27.0), (18.0, 29.0), (19.0, 31.0), (20.0, 33.0)]



相關用法


注:本文由純淨天空篩選整理自Sunitamamgai大神的英文原創作品 Python PIL | ImagePath.Path.map() method。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。