Inserting a function in Edit/Selection/Enlarge numeric dialog box

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

Inserting a function in Edit/Selection/Enlarge numeric dialog box

ayubsulong
Dear ImageJ users,

I'm working with this macro,

--
//apm_oval_v3
//create oval for every slice of apm


dir1 = getDirectory("Choose Source Directory ");
dir2 = getDirectory("Choose Destination Directory ");
list = getFileList(dir1);

setBatchMode(true);
for (i=0; i<list.length; i++) {
showProgress(i+1, list.length);
open(dir1+list[i]);

run("Create Selection");
run("Make Inverse");
run("Enlarge...", "enlarge=0.01");
run("Make Inverse");
run("Enlarge...", "enlarge=-0.01");
run("Specify...", "oval");
// run("Enlarge...", "enlarge=-0.01*x");
run("Enlarge...", "enlarge=-0.01");
run("Clear Outside");
run("Invert");
run("Make Inverse");
run("Invert");


saveAs("Tiff", dir2+list[i]);

close();
 }

--

I have 800 circular images (few examples in attachment). As indicated with
the arrow,

command run("Enlarge...", "enlarge=-0.01"); will key in -0.01 in the
numeric window ENLARGE.

How do I insert a function (-0.01*3x) in that numeric window. Where should
i define the 'x' and the multiplication process. I got Macro error message
"Numeric value expected in run() function"

I'm new to ImageJ and any help would be appreciated.

Cheers,

Ayub

--
ImageJ mailing list: http://imagej.nih.gov/ij/list.html

circle0000.tif (355K) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: Inserting a function in Edit/Selection/Enlarge numeric dialog box

Michael Schmid
Hi Ayub,

you can set a variable to put the result of a calculation into a list of parameters:
  enlargeBy = -0.01*3x;
  run("Enlarge...", "enlarge=&enlargeBy");
As an alternative, use String concatenation:
  run("Enlarge...", "enlarge="+(-0.01*3x));

Michael
________________________________________________________________

On 2013-Mar-19, at 4:03, mohd ayub sulong wrote:

> Dear ImageJ users,
>
> I'm working with this macro,
>
> --
> //apm_oval_v3
> //create oval for every slice of apm
>
>
> dir1 = getDirectory("Choose Source Directory ");
> dir2 = getDirectory("Choose Destination Directory ");
> list = getFileList(dir1);
>
> setBatchMode(true);
> for (i=0; i<list.length; i++) {
> showProgress(i+1, list.length);
> open(dir1+list[i]);
>
> run("Create Selection");
> run("Make Inverse");
> run("Enlarge...", "enlarge=0.01");
> run("Make Inverse");
> run("Enlarge...", "enlarge=-0.01");
> run("Specify...", "oval");
> // run("Enlarge...", "enlarge=-0.01*x");
> run("Enlarge...", "enlarge=-0.01");
> run("Clear Outside");
> run("Invert");
> run("Make Inverse");
> run("Invert");
>
>
> saveAs("Tiff", dir2+list[i]);
>
> close();
> }
>
> --
>
> I have 800 circular images (few examples in attachment). As indicated with
> the arrow,
>
> command run("Enlarge...", "enlarge=-0.01"); will key in -0.01 in the
> numeric window ENLARGE.
>
> How do I insert a function (-0.01*3x) in that numeric window. Where should
> i define the 'x' and the multiplication process. I got Macro error message
> "Numeric value expected in run() function"
>
> I'm new to ImageJ and any help would be appreciated.
>
> Cheers,
>
> Ayub
>
> --
> ImageJ mailing list: http://imagej.nih.gov/ij/list.html
> <circle0000.tif>

--
ImageJ mailing list: http://imagej.nih.gov/ij/list.html
Reply | Threaded
Open this post in threaded view
|

Re: Inserting a function in Edit/Selection/Enlarge numeric dialog box

ayubsulong
Hi Michael,

Many thanks for your quick reply. Can you please elaborate more on
setting a variable and parameters.

Cheers,

Ayub
Reply | Threaded
Open this post in threaded view
|

Re: Inserting a function in Edit/Selection/Enlarge numeric dialog box

Michael Schmid
Hi Ayub,

have a look at the documentation of the macro language:
  http://rsb.info.nih.gov/ij/developer/macro/macros.html#run

At the end of the section "Using run() to execute ImageJ commands", you will find a short description on how to put variables into the argument string of a 'run(...' command.

Michael
________________________________________________________________
On Mar 20, 2013, at 01:15, ayubsulong wrote:

> Hi Michael,
>
> Many thanks for your quick reply. Can you please elaborate more on
> setting a variable and parameters.
>
> Cheers,
>
> Ayub
>
>
>
> --
> View this message in context: http://imagej.1557.n6.nabble.com/Inserting-a-function-in-Edit-Selection-Enlarge-numeric-dialog-box-tp5002282p5002309.html
> Sent from the ImageJ mailing list archive at Nabble.com.
>
> --
> ImageJ mailing list: http://imagej.nih.gov/ij/list.html

--
ImageJ mailing list: http://imagej.nih.gov/ij/list.html
Reply | Threaded
Open this post in threaded view
|

Re: Inserting a function in Edit/Selection/Enlarge numeric dialog box

ayubsulong
In reply to this post by Michael Schmid
Hi Michael,

Thanks for initiating the spirit to dig in Java based macro.

This is what I needed,

//APM_oval
//the equation in Macro loop

sdir = getDirectory("Choose Source Directory ");
ddir = getDirectory("Choose Destination Directory ");
list = getFileList(sdir);
       

        setForegroundColor(255, 255, 255);
        setBackgroundColor(0, 0, 0);

                setBatchMode(true);
                for (i=1; i<list.length; i++) {
        showProgress(i+1, list.length);

        open(sdir+list[i]);

                                run("Create Selection");
                                run("Make Inverse");
                                run("Enlarge...", "enlarge=2");
                                run("Make Inverse");
                                run("Enlarge...", "enlarge=-2");

                                r = 355;

                                        r_prime=sqrt((r*r)-(abs(r-i)*abs(r-i)));

                                run("Specify...", "width="+2*r_prime+" height="+2*r_prime+" x=390  y=358 oval    centered");
       

                                run("Clear Outside");
                                run("Invert");
                                run("Make Inverse");
                                run("Invert");
       

        saveAs("Tiff", ddir+list[i]);

                        close();
        }