Uni-Tech Adelaide: My First Red-Eye Removal

QUESTION: “If 'coding' would be your superpower, what would you do?”

For a start, watch the great motivational videos What most schools don't teach and The hour of code!
All slides are available online as a PPTX and as a PDF.
The Jython Environment for Students is available online as well.
And if you are looking for all the pictures that we are using today: you can download them here.

Slide 17 - Our first picture recipe

def decreaseRed(picture):
  for p in getPixels(picture):
    value=getRed(p)
    setRed(p,value*0.5)

Note: instead of lines line
  file="/Users/guzdial/mediasources/katie.jpg"
use the line
  file=pickAFile()
and then find the file under
  d:\JEC\JES_MediaSources
when you are in room EM106.

Slide 43 - Working the pixels by number

def decreaseRed2(picture):
  for x in range(0,getWidth(picture)):
    for y in range(0,getHeight(picture)):
      px = getPixel(picture,x,y)
      value = getRed(px)
      setRed(px,value*0.5)

Slide 45 - Removing Red Eyes

def removeRedEye(pic,startX,startY,endX,endY,replacementcolor):
  red = makeColor(255,0,0)
  for x in range(startX,endX):
    for y in range(startY,endY):
      currentPixel = getPixel(pic,x,y)
      if (distance(red,getColor(currentPixel)) < 165):
        setColor(currentPixel,replacementcolor)