title: Jython convert picture to grayscale and then negate it
body: <p>Please bear with me, I've only started python a few weeks ago.</p>
  <p>I am using JES.</p>
  <p>I have made a function to convert a picture to grayscale. I created two names for each color r and  r1, g and g1, b and b1. The idea behind this, was to keep the original values in memory, so the picture could be restored to it's original color.</p>
  <pre><code>def grayScale(pic):
    for p in getPixels(pic):
      r = int(getRed(p))
      g = int(getGreen(p))
      b = int(getBlue(p))//I have tried this with and without the int()
      r1=r
      g1=g
      b1=b
      new = (r + g + b)/3
      color= makeColor(new,new,new)
      setColor(p, color)
     
      
  def restoreColor(pic):
    for p in getPixels(pic):
      setColor (p, makeColor(r1,g1,b1))
  </code></pre>
  <p>It's not working. <code>The error: &quot;local or global name could not be found.&quot;</code></p>
  <p>I understand why I am getting this error.</p>
  <p>However, if I try to define them within restoreColor, it will give the grayscale values.</p>
  <p>I understand why I am getting this error, but don't know how to format my code, to hold a name value. I have looked at questions about local and global variables/names; but I cannot work out, within the rudimentary syntax I have learnt, how to do this.</p>
  <p>The problem is:</p>
  <p>How to I create names and get their values for the original  (red, green, blue) that I can then use later in another function? Everything I have tried, has returned the altered (grayscale) values.</p>