athletics67
11/11/2018 - 7:42 PM

removeRedEye.py

#red eye red color: 223,68,84
def removeRedEye(pic):
  redEyeColor = makeColor(223,68,84)
  pixels = getPixels(pic)
  for p in pixels:
    pixelColor = getColor(p)
    dist = distance(pixelColor,redEyeColor)
    if(dist < 62):
      #desaturate the color if it's too close to redeye
      r = getRed(p)
      g = getGreen(p)
      b = getBlue(p)
      luminance = r*0.299 + g*0.587 + b*0.114
      newColor = makeColor(luminance,luminance,luminance)
      setColor(p,newColor)