call a pluginfilter

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

call a pluginfilter

Thomas Boudier
Hi,

I would like to create a selection from a mask so I used the
ThresholdToSelection class but I have trouble to make it work properly,
when I use directly IJ.run("Create Selection") it works perfectly, but I
would like to hide my image. Any idea ? Thanks.

Thomas


Here a small plugin :

import ij.*;
import ij.process.*;
import ij.gui.*;
import java.awt.*;
import ij.plugin.filter.*;

public class Test_ implements PlugInFilter {
        ImagePlus imp;

        public int setup(String arg, ImagePlus imp) {
                this.imp = imp;
                return DOES_ALL;
        }

        public void run(ImageProcessor ip) {
                imp.lock();
                ThresholdToSelection tts = new ThresholdToSelection();
                tts.setup("setup", imp);
                tts.run(ip);
                IJ.write("sel="+ip.getRoi());
                IJ.write("sel="+imp.getRoi());
                imp.unlock();
                IJ.run("Create Selection");
                IJ.write("sel="+ip.getRoi());
                IJ.write("sel="+imp.getRoi());
        }

}


--
    /**********************************************************/
       Thomas Boudier, MCU Université Pierre et Marie Curie,
       IFR 83. Bat B 7ème étage, porte 709, Jussieu.
       Tel : 01 44 27 20 11  Fax : 01 44 27 22 91
/*******************************************************/
Reply | Threaded
Open this post in threaded view
|

Re: call a pluginfilter

Albert Cardona
Thomas Boudier wrote:
> Hi,
>
> I would like to create a selection from a mask so I used the
> ThresholdToSelection class but I have trouble to make it work properly,
> when I use directly IJ.run("Create Selection") it works perfectly, but I
> would like to hide my image. Any idea ? Thanks.



If by hiding an image you mean you don't want the image ever to be shown,
just don't create a PlugInFilter for the task. Use the
ThreshholdToSelection directly like you do in the body of the run
method, and then call imp.getRoi().

That is how I do it in the AmiraImporter class:

http://repo.or.cz/w/trakem2.git?a=blob;f=ini/trakem2/io/AmiraImporter.java;h=fbb8616f6e0769362a5a23cabeb68c5d6201697f;hb=b67bf272c693c543d47abf0db4d5a945f0452a25#l171

Hope that helped.

Albert

--
Albert Cardona
http://albert.rierol.net
Reply | Threaded
Open this post in threaded view
|

Re: call a pluginfilter

Thomas Boudier
Hi Albert,

This is exactly what I did but nothing happened so I tested with IJ.Run
and it worked. The pluginfilter Test_ is just here to test the call to
ThresholdToSelection. I use 1.42h with java 1.6.0_10.

Thomas


Albert Cardona a écrit :

> Thomas Boudier wrote:
>> Hi,
>>
>> I would like to create a selection from a mask so I used the
>> ThresholdToSelection class but I have trouble to make it work properly,
>> when I use directly IJ.run("Create Selection") it works perfectly, but I
>> would like to hide my image. Any idea ? Thanks.
>
>
>
> If by hiding an image you mean you don't want the image ever to be shown,
> just don't create a PlugInFilter for the task. Use the
> ThreshholdToSelection directly like you do in the body of the run
> method, and then call imp.getRoi().
>
> That is how I do it in the AmiraImporter class:
>
> http://repo.or.cz/w/trakem2.git?a=blob;f=ini/trakem2/io/AmiraImporter.java;h=fbb8616f6e0769362a5a23cabeb68c5d6201697f;hb=b67bf272c693c543d47abf0db4d5a945f0452a25#l171 
>
>
> Hope that helped.
>
> Albert
>

--
   /**********************************************************/
      Thomas Boudier, MCU Université Pierre et Marie Curie,
      IFR 83. Bat B 7ème étage, porte 709, Jussieu.
      Tel : 01 44 27 20 11  Fax : 01 44 27 22 91
/*******************************************************/