PIL是Python Imaging Library,它為python解釋器提供了圖像編輯函數。的Image
模塊提供了一個具有相同名稱的類,用於表示PIL圖像。該模塊還提供了許多出廠函數,包括從文件加載圖像和創建新圖像的函數。
Image.point()
通過查找表或函數映射此圖像。
用法: Maps this image through a lookup table or function.
參數:
lut:一個查找表,在圖像中每個波段包含256個值(如果self.mode ==“ I”且mode == “L”,則為65336)。可以改用函數,它應使用單個參數。對每個可能的像素值調用一次該函數,並將結果表應用於圖像的所有波段。
mode:輸出模式(默認與輸入相同)。在當前版本中,僅當源圖像的模式為“L”或“P”且輸出的圖像模式為“1”或源圖像的模式為“I”且輸出模式為“L”時,才可以使用此選項。
返回值:Image對象。
使用的圖片:
# importing Image class from PIL package
from PIL import Image
# creating a object
im = Image.open(r"C:\Users\System-Pc\Desktop\home.png")
# using point function
threshold = 191
im = im.point(lambda p:p >value threshold and 255)
im.show()
輸出:
另一個示例:此處更改閾值。
使用的圖片:
# importing Image class from PIL package
from PIL import Image
# creating a object
im = Image.open(r"C:\Users\System-Pc\Desktop\home.png")
# using point function
threshold = 120
im = im.point(lambda p:p > threshold and 255)
im.show()
輸出:
相關用法
- Python next()用法及代碼示例
- Python os.dup()用法及代碼示例
- Python set()用法及代碼示例
- Python Decimal max()用法及代碼示例
- Python PIL ImageOps.fit()用法及代碼示例
- Python os.rmdir()用法及代碼示例
- Python sympy.det()用法及代碼示例
- Python Decimal min()用法及代碼示例
- Python os.readlink()用法及代碼示例
- Python os.writev()用法及代碼示例
- Python os.readv()用法及代碼示例
- Python PIL RankFilter()用法及代碼示例
- Python os.rename()用法及代碼示例
- Python os.sendfile()用法及代碼示例
注:本文由純淨天空篩選整理自Sunitamamgai大神的英文原創作品 Python PIL | Image.point() method。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。