from PIL import Image
im=Image.open("luffy.jpg")
def bleu(image):
(c,l)=image.size
imagebleu=Image.new('RGB',(c,l))
for x in range(c):
for y in range(l):
pixel=image.getpixel((x,y))
if pixel[0]<... or pixel[1]<... or pixel[2]>... :
p=(pixel[0],pixel[1],pixel[2])
else:
gris=int((pixel[0]+pixel[1]+pixel[2])/3)
p=(gris,gris,gris)
imagebleu.putpixel((x,y),p)
imagebleu.save("imgbleu.jpg")
imagebleu.show()