Access ImageJ Functions in own plugin

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

Access ImageJ Functions in own plugin

Alexander Haid
Hello ImageJ-List,

is it possible to access the function "Process/Binary/Watershed" from  
my own java plugin? If so, how?

Thank you,
- alex
Reply | Threaded
Open this post in threaded view
|

Antwort: Access ImageJ Functions in own plugin

Joachim Wesner
Easy!

If you are talking about a Java plugin as I assume, use IJ.run("<command>",
"<args>) like the run() in macros!


Mit freundlichen Grüßen / Best regards

Joachim Wesner
Projektleiter Optik Technologiesysteme




                                                                           
             Alexander Haid                                                
             <[hidden email]                                            
             >                                                          An
             Gesendet von:              [hidden email]                
             ImageJ Interest                                         Kopie
             Group                                                        
             <[hidden email].                                       Thema
             GOV>                       Access ImageJ Functions in own    
                                        plugin                            
                                                                           
             10.09.2009 11:06                                              
                                                                           
                                                                           
              Bitte antworten                                              
                    an                                                    
              ImageJ Interest                                              
                   Group                                                  
             <[hidden email].                                            
                   GOV>                                                    
                                                                           
                                                                           




Hello ImageJ-List,

is it possible to access the function "Process/Binary/Watershed" from
my own java plugin? If so, how?

Thank you,
- alex



______________________________________________________________________
This email has been scanned by the MessageLabs Email Security System.
For more information please visit http://www.messagelabs.com/email 
______________________________________________________________________
Reply | Threaded
Open this post in threaded view
|

Re: Access ImageJ Functions in own plugin

Michael Schmid
In reply to this post by Alexander Haid
Hi Alex,

the most simple way is recording it as a macro and using the  
Edit>Convert to Plugin function. This works well with most commands.

It will give you
    IJ.run("Watershed");

This won't work it the image is locked; in that case you have to  
simulate the way how the (Extended)PlugInFilter is called by the  
PlugInFilterRunner of ImageJ. This is a little bit more complicated;  
in your case it would only work for single images (not for composite  
images/stacks) and roughly look like the following:

   ImagePlus imp = ...  //your ImagePlus containing the image
   EDM edm = new EDM(); //get an instance of the PlugInFilter that  
does the job.
     //See Plugins>Utilities>Find Commands (details) if you don't  
know which PlugInFilter does the job.
   edm.setup("watershed", imp);
   int flags = edm.showDialog (imp, null, null); //no dialog; only  
used to initialize a few things
   //maybe check whether flags is PlugInFilter.DONE; that would be an  
error (no binary input)
   edm.run (imp.getProcessor());


Michael
________________________________________________________________

On 10 Sep 2009, at 11:06, Alexander Haid wrote:

> Hello ImageJ-List,
>
> is it possible to access the function "Process/Binary/Watershed"  
> from my own java plugin? If so, how?
>
> Thank you,
> - alex
Reply | Threaded
Open this post in threaded view
|

Re: Access ImageJ Functions in own plugin

Alexander Haid
In reply to this post by Alexander Haid
Hi to you both,

thanks for your replys.

I managed to do it with an EDM Object like Michael suggested. Works great.
Just one more question: now it works with white as background and black for
the objects. Is it possible to set it the other way round? I could simply
invert the ip!?

Thanks,
 - alex
Reply | Threaded
Open this post in threaded view
|

Re: Access ImageJ Functions in own plugin

Michael Schmid
Hi Alex,

you could invert the ImageProcessor, invert the LUT (faster) or set  
the binary options to black background (Prefs.blackBackground).

By the way, if you update to the current daily build of ImageJ, it  
should also work without the "edm.showDialog" step.

Michael
________________________________________________________________

On 11 Sep 2009, at 15:26, Alexander Haid wrote:

> Hi to you both,
>
> thanks for your replys.
>
> I managed to do it with an EDM Object like Michael suggested. Works  
> great.
> Just one more question: now it works with white as background and  
> black for
> the objects. Is it possible to set it the other way round? I could  
> simply
> invert the ip!?
>
> Thanks,
>  - alex