上课记录
from PIL import Imagei=1
j=1
img=Image.open("test.jpg")
width=img.size
height=img.size
for i in range(0,width):
for j in range(0,height):
data=(img.getpixel((i,j)))
if (data>=128 and data>=128 and data>=128):
img.putpixel((i,j),(250,250,250))
else:
img.putpixel((i,j),(20,20,20))
img.save("starsyellow.png")
print("修改完成")
from PIL import Image
i=1
j=1
img=Image.open("run.jpg")
width=img.size
height=img.size
for i in range(0,width):
for j in range(0,height):
data=(img.getpixel((i,j)))
if (data<=234 and data<=234 and data<=234):
img.putpixel((i,j),(255,255,255))
if (data>234 and data>234 and data>234):
img.putpixel((i,j),(0,0,0))
img.save("starsyellow.png")
print("修改完成")
页:
[1]