Login  Register

Re: Filler functions (clearOutside etc)

Posted by Wayne Rasband on Mar 22, 2009; 4:06am
URL: http://imagej.273.s1.nabble.com/Filler-functions-clearOutside-etc-tp3693218p3693220.html

> P.S. now I found workaround for "Image is locked" problem by using
> imp.unlock(); but still would like to know how to use .clearOutside  
> method
> without IJ.run

You can avoid the "Image is locked" errors by having your plugin  
implement PlugIn instead of PlugInFilter. The v1.42l daily build adds  
fillOutside(Roi), Fill(Roi) and draw(Roi) methods to the  
ImageProcessor class. Here is a JavaScript example:

    IJ.run("Clown (14K)");
    IJ.makeOval(91, 41, 151, 108);
    imp = IJ.getImage();
    roi = imp.getRoi();
    ip = imp.getProcessor();
    ip.snapshot();
    ip.setColor(Color.blue);
    ip.setLineWidth(10);
    ip.draw(roi);
    imp.updateAndDraw();
    IJ.wait(2000);
    ip.reset();
    ip.fill(roi);
    imp.updateAndDraw();
    IJ.wait(2000);
    ip.reset();
    ip.fillOutside(roi);
    imp.updateAndDraw();

-wayne