PIL是Python Imaging Library,它為python解釋器提供了圖像編輯函數。的ImageChops模塊包含許多算術圖像運算,稱為通道運算(“chops”)。這些可以用於各種目的,包括特殊效果,圖像合成,算法繪畫等。
PIL.ImageChops.logical_xor()
方法在兩個圖像之間應用邏輯XOR。至少一張圖像必須具有“1”模式。
圖片1
圖片2:
用法: PIL.ImageChops.logical_xor(image1, image2)
參數:
image1:第一張圖片
image2:第二張圖片
返回類型:圖片
# Importing Image and ImageChops module from PIL package
from PIL import Image, ImageChops
# creating a image1 object
im1 = Image.open(r"C:\Users\sadow984\Desktop\a2.PNG") .convert("1")
# creating a image2 object
im2 = Image.open(r"C:\Users\sadow984\Desktop\x5.PNG") .convert("1")
# applying logical_xor method
im3 = ImageChops.logical_xor(im1, im2)
im3.show()
輸出:
PIL.ImageChops.invert()
方法反轉圖像(通道)。
用法: PIL.ImageChops.invert(image)
參數:
image1:圖片
返回類型:圖片
# Importing Image and ImageChops module from PIL package
from PIL import Image, ImageChops
# creating a image1 object
im1 = Image.open(r"C:\Users\sadow984\Desktop\a2.PNG")
# applying invert method
im3 = ImageChops.invert(im1)
im3.show()
輸出:
相關用法
- Python numpy.invert()用法及代碼示例
- Python next()用法及代碼示例
- Python set()用法及代碼示例
- Python os.dup()用法及代碼示例
- Python os.kill()用法及代碼示例
- Python sympy.tan()用法及代碼示例
- Python os.mkdir()用法及代碼示例
- Python sympy.has()用法及代碼示例
- Python PIL putalpha()用法及代碼示例
- Python os.setgroups()用法及代碼示例
注:本文由純淨天空篩選整理自ravikishor大神的英文原創作品 Python PIL | logical_xor() and invert() method。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。