calling macros from plugins

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
7 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

calling macros from plugins

chepe santacruz
hello,

Is there a way to use/call  macros (built-in or user defined) in my ImageJ
plugins?

thanks for your help,

Billy Bustillo
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: calling macros from plugins

Thomas Boudier-2
Hi,

Simply as :

IJ.run("Run... ", "run=..../mymacro.txt");

Thomas

chepe santacruz a écrit :

> hello,
>
> Is there a way to use/call  macros (built-in or user defined) in my
> ImageJ plugins?
>
> thanks for your help,
>
> Billy Bustillo
>
>

--
/*************************************************/
    Thomas Boudier, MCU Université Paris 6,
    Imagerie Integrative,INSERM - Institut Curie.
    Tel : 01 69 86 31 72  Fax : 01 69 07 53 27
/*************************************************/
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: calling macros from plugins

Wayne Rasband
In reply to this post by chepe santacruz
> Is there a way to use/call  macros (built-in or user defined) in
> my ImageJ plugins?

You can call a macro inline using IJ.runMacro():

       String macro = "angle = getArgument();"+
           "getRawStatistics(area, mean);"+
           "setBackgroundColor(mean, mean, mean);"+
           "run('Arbitrarily...', 'interpolate fill angle='+angle);";
       double angle = 15;
       IJ.runMacro(macro, ""+angle);

Or call a macro located in the macros folder using IJ.runMacroFile():

       // run the Polygon.txt macro in ..ImageJ/macros
       IJ.runMacroFile("Polygon", "argument");

-wayne
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Median of an array

Pedro Ramos
Dear all,

I use to manage well things when doing macros, but I am completely lost when
I have to work with plugins. So I'll appreciate some help.

I would like to calculate the median of an array in a plugin, and I haven't
found a way to do it by browsing through the stored messages posted in the
mailing list. Can anyone tell me how to calculate the median of an array in
a plugin. Thanks a lot.

Pedro
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Median of an array

Gabriel Landini
On Wednesday 27 July 2005 10:47, Pedro Ramos wrote:
> I would like to calculate the median of an array in a plugin, and I haven't
> found a way to do it by browsing through the stored messages posted in the
> mailing list. Can anyone tell me how to calculate the median of an array in
> a plugin. Thanks a lot.

Sort the array of n elements, then
take the middle value if n=odd
take the average of the 2 middle values if n=even

Cheers,
G.
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Median of an array

Pedro Ramos
Ok, that is the way to calculate the median of an array, I know that. I was
wondering if there is a command to do it automatically without programming
the whole process you have described. But thanks anyhow for your help.
That's how I'll proceed if I can't find a "shortcut".

Pedro
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Median of an array

Ludgate, David
In reply to this post by Pedro Ramos
It's a general programming question, not image specific, so its not
likely to be in the imageJ library. However, you can almost certainly
find open source sorting code you could borrow :)
If you're dealing with a reasonably small array, I'd use selection sort
or insertion sort (google will give you lots of info on either) because
they are both simple and easy to understand.
If you have to sort arrays frequently or the arrays are pretty large (in
the hundreds of items or more), it might be worth looking up a faster
algorithm. Quick sort is the best, in general, and doesn't require much
code, but the algorithm is a nightmare to understand at first. It's also
massively recursive.
Hope this helps!
david

-----Original Message-----
From: ImageJ Interest Group [mailto:[hidden email]] On Behalf Of
Pedro Ramos
Sent: Wednesday, July 27, 2005 3:26 AM
To: [hidden email]
Subject: Re: Median of an array


Ok, that is the way to calculate the median of an array, I know that. I
was
wondering if there is a command to do it automatically without
programming
the whole process you have described. But thanks anyhow for your help.
That's how I'll proceed if I can't find a "shortcut".

Pedro
Loading...