pip install pillow python from PIL import Image from PIL import ImageEnhance python image = Image.open("photo.jpg") python for x in range(image.width): for y in range(image.height): red, green, blue = image.getpixel((x, y)) if red > 50 and green < 50 and blue < 50: python for x in range(image.width): for y in range(image.height): red, green, blue = image.getpixel((x, y)) if red > 50 and green < 50 and blue < 50: image.putpixel((x, y), (0, green, blue)) python image.save("photo_without_red_eye.jpg") python from PIL import Image from PIL import ImageEnhance def remove_red_eye(image_path): image = Image.open(image_path) for x in range(image.width): for y in range(image.height): red, green, blue = image.getpixel((x, y)) if red > 50 and green < 50 and blue < 50: image.putpixel((x, y), (0, green, blue)) image.save("photo_without_red_eye.jpg") remove_red_eye("photo.jpg")


上一篇:
下一篇:
切换中文