from PIL import Image
img = Image.open(“图片路径”)
img = img.convert(“L”) #灰度化
img.show()
imgdata = list(img.getdata())
print(imgdata)
addlist = []
for i in range(len(imgdata)):
if imgdata[i]>250:
addlist.append(imgdata[i]-100)
else:
addlist.append(imgdata[i])
img.putdata(addlist)
img.show()
date: 2018-09-25 22:44:22