# A Large Cross Blur

def blurLargeCross(filename):
  source = makePicture(filename)
  target = makePicture(filename)
  
  # loop for all pixels
  for x in range(3,getWidth(source)-1):
    for y in range(3,getHeight(source)-1):
      # Get all required pixels for the pixel blur
      uppertop =     getPixel(source, x, y-2)
      lowerbottom =  getPixel(source, x, y+2)
      topmiddle =    getPixel(source, x, y-1)
      farleft =      getPixel(source, x-2, y)
      farright =     getPixel(source, x+2, y)
      bottommiddle = getPixel(source, x, y+1)
      middleleft =   getPixel(source, x-1, y)
      middleright =  getPixel(source, x+1, y)
      center =       getPixel(target, x, y)

      # Use the '\' character to tell Python that
      # a commend continues on the next line
      # Set the new red value
      newRed = (getRed(uppertop) + getRed(lowerbottom) + \
                getRed(topmiddle) + getRed(farleft) + \
                getRed(farright) + getRed(bottommiddle) + \
                getRed(middleleft) + getRed(middleright) + \
                getRed(center)) / 9
      # Set the new green value
      newGreen = (getGreen(uppertop) + getGreen(lowerbottom) + \
                  getGreen(topmiddle) + getGreen(farleft) + \
                  getGreen(farright) + getGreen(bottommiddle) + \
                  getGreen(middleleft) + getGreen(middleright) + \
                  getGreen(center)) / 9
      # Set the new blue value
      newBlue = (getBlue(uppertop) + getBlue(lowerbottom) + \
                 getBlue(topmiddle) + getBlue(farleft) + \
                 getBlue(farright) + getBlue(bottommiddle) + \
                 getBlue(middleleft) + getBlue(middleright) + \
                 getBlue(center)) / 9
      # Set the new color of the center pixel
      setColor(center, makeColor(newRed, newGreen, newBlue))

  return target
