I need to change pixel color of an image in python. Except for the pixel value (255, 0, 0) red I need to change every pixel color value into black (0, 0, 0). I tried the following code but it doesn't helped.
from PIL import Image
im = Image.open('A:ex1.jpg')
for pixel in im.getdata():
if pixel == (255,0,0):
print "Red coloured pixel"
else:
pixel = [0, 0, 0]
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…