python 替换图片中的像素
from PIL import Image import time img = Image.open('luban/jietu1631965285306c.jpg') img = img.convert('RGB') pixels = img.load() start=time.time() for i in range(img.size[0]): for j in range(img.size[1]): if (pixels[i,j][0]>=90 and pixels[i,j][0]<=160) and (pixels[i,j][1]>=130 and pixels[i,j][1]<=220) and (pixels[i,j][2]>=150 and pixels[i,j][2]<=240): # if pixels[i,j] == (225, 225, 225): # print('wefwef'); pixels[i,j] = (0,0,0) img.save('example.jpg') end=time.time() print('Running time: %s Seconds'%(end-start))