|
马上注册,结交更多好友,享用更多功能^_^
您需要 登录 才可以下载或查看,没有账号?立即注册
x
from PIL import Image
i=1
j=1
img=Image.open("test.jpg")
width=img.size[0]
height=img.size[1]
for i in range(0,width):
for j in range(0,height):
data=(img.getpixel((i,j)))
if (data[0]>=128 and data[1]>=128 and data[2]>=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[0]
height=img.size[1]
for i in range(0,width):
for j in range(0,height):
data=(img.getpixel((i,j)))
if (data[0]<=234 and data[1]<=234 and data[2]<=234):
img.putpixel((i,j),(255,255,255))
if (data[0]>234 and data[1]>234 and data[2]>234):
img.putpixel((i,j),(0,0,0))
img.save("starsyellow.png")
print("修改完成") |
|