python PIL獲取圖片像素點

from PIL import Image

# 打開要處理的圖像
img_src = Image.open('sun.png')

# 轉換圖片的模式爲RGBA
img_src = img_src.convert('RGBA')

# 獲得文字圖片的每個像素點
src_strlist = img_src.load()

# 100,100 是像素點的座標
data = src_strlist[100, 100]
# 結果data是一個元組包含這個像素點的顏色信息    栗子:(0, 0, 0, 255)

 

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章