Severian
Severian

Reputation: 11

how to repeat in Fiji

I was wondering if it is possible to write in into macro to repeat just a part of the macro in imageJ.

I have a code

selectWindow("Red");
run("Duplicate...", " ");
rename("Red-Dup");
run("8-bit");
run("Subtract...", "value=25");
run("Duplicate...", " ");
imageCalculator("Add create", "Red-Dup","Red-Dup-1");
run("Subtract...", "value=25");
close("Red-Dup");
close("Red-Dup-1");

and instead of copying and pasting it 20 times, I would like to find a function to run it let's say x20.

Thank you for your help!

Upvotes: 0

Views: 750

Answers (1)

Petra
Petra

Reputation: 63

You only need a for loop:

num_of_repeat = 20
for (i = 0; i < num_of_repeat; i++){

   selectWindow("Red");
   run("Duplicate...", " ");
   rename("Red-Dup");
   run("8-bit");
   run("Subtract...", "value=25");
   run("Duplicate...", " ");
   imageCalculator("Add create", "Red-Dup","Red-Dup-1");
   run("Subtract...", "value=25");
   close("Red-Dup");
   close("Red-Dup-1");

}

And you can change the num_of_repeat, if you want to change the number of repetition.

Upvotes: 0

Related Questions