PIL是Python Imaging Library,它為python解釋器提供了圖像編輯函數。
ImageChops.screen()方法-
此方法用於將兩個倒置的圖像彼此疊加。
用法: ImageChops.screen(image1, image2) 參數: image1 first image image2 second image 返回值: An Image
# This will import Image and ImageChops modules 
from PIL import Image, ImageChops 
  
# Opening Images 
im = Image.open(r"C:\Users\Admin\Pictures\images.png") 
im2 = Image.open(r"C:\Users\Admin\Pictures\download.PNG") 
  
# superimposing images im and im2 
im3 = ImageChops.screen(im, im2) 
  
# showing resultant image 
im3.show()輸出:

ImageChops.offset()方法-
此方法返回圖像的副本,其中數據已偏移給定距離。數據環繞邊。如果省略yoffset,則假定它等於xoffset。
用法: ImageChops.offset(image1, xoffset, yoffset = None)
參數:
image:它是提供偏移量的圖像
xoffset:水平距離
yoffset:它是垂直距離,如果省略,則將兩個距離設置為相同。
返回值:原始圖像的副本
# This will import Image and ImageChops modules 
from PIL import Image, ImageChops 
  
# Opening Images 
im = Image.open(r"C:\Users\Admin\Pictures\images.png") 
im2 = Image.open(r"C:\Users\Admin\Pictures\download.PNG") 
  
# Here, xoffset is given 100 
# yoffset wil automaticallly set to 100 
im3 = ImageChops.offset(im, 140) 
  
# showing resultant image 
im3.show()輸出:

相關用法
- Python next()用法及代碼示例
 - Python os.dup()用法及代碼示例
 - Python set()用法及代碼示例
 - Python hash()用法及代碼示例
 - Python os.times()用法及代碼示例
 - Python PIL BoxBlur()用法及代碼示例
 - Python sympy.ones()用法及代碼示例
 - Python dict pop()用法及代碼示例
 - Python sys.getdefaultencoding()用法及代碼示例
 - Python Numpy np.fft()用法及代碼示例
 - Python os.setgroups()用法及代碼示例
 - Python os.getgroups()用法及代碼示例
 - Python PyTorch tan()用法及代碼示例
 - Python object()用法及代碼示例
 
注:本文由純淨天空篩選整理自sanjeev2552大神的英文原創作品 Python PIL | ImageChops.screen() and ImageChops.offset() method。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。
