Filler functions (clearOutside etc)

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

Filler functions (clearOutside etc)

SUBSCRIBE IMAGEJ test
Hello,
I am sorry for dumb question but I was not able to find the answer
anywhere in the internet...
I am writing the plugin and want to use "Clear Outside" function. In
the API, I found "public void clearOutside(ImageProcessor ip)" in
Filler module. But I didn't got how to use it in the plugin. If I
create Filler first, by writing "Filler filler = new Filler();" and
then try to call the function by "filler.clearOutside(ip);" (all this
is in "public void run(ImageProcessor ip)") - I got
java.lang.NullPointerException "at
ij.plugin.filter.Filler.clearOutside(Filler.java:186)".
 Alternatively, I tried to use simple IJ.run("Clear Outside"); but in
this case I got a message "Image is locked"...
I will be very grateful if anybody explain what should I do here.
Thanks in advance!
Reply | Threaded
Open this post in threaded view
|

Re: Filler functions (clearOutside etc)

SUBSCRIBE IMAGEJ test
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
Reply | Threaded
Open this post in threaded view
|

Re: Filler functions (clearOutside etc)

Wayne Rasband
> 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