title: NameError: name 'ip' is not defined
body: <p>I am getting a syntax error when trying to run the Jython plugin in imageJ.</p>
  
  <p>There is Java that starts with</p>
  
  <pre><code>import ij.plugin.filter.PlugInFilter;
  import ij.ImagePlus;
  import ij.process.ImageProcessor;
  import org.python.util.PythonInterpreter;
  public class Invert_Filter implements PlugInFilter {
    public int setup(String arg, ImagePlus imp) {
      // inform ImageJ that this plugin filter only handles 8 bit grayscale images
      return DOES_8G;
    }
    public void run(ImageProcessor ip) {
      // create a Python interpreter
      PythonInterpreter py = new PythonInterpreter();
      // pass the image processor of the current image to the Python interpreter
      py.set("ip", ip);
      // execute the Python file containing the source code for this ImageJ plugin filter
      py.execfile("C:\\ImageJ\\plugins\\Invert_Filter.py");
    }
  }
  </code></pre>
  
  <p>And Python code:</p>
  
  <pre><code># "ip" is the image processor of the current image that is passed in from ImageJ
  ip.invert()
  </code></pre>
  
  <p>When running this I get:</p>
  
  <blockquote>
    <p>NameError: name 'ip' is not defined</p>
  </blockquote>