First time macro: combine Do loop with recorded macro
Posted by Alex Valm on Sep 30, 2009; 3:16am
URL: http://imagej.273.s1.nabble.com/First-time-macro-combine-Do-loop-with-recorded-macro-tp3690980.html
Hello,
I am trying to combine a do ... while loop with a macro that I have
recorded and am having trouble.
What I would like to do is take an image, say 1000 x 1000 pixels, and
chop it up into smaller square ROIs, each 100 x 100 pixels, starting
from the top left of the image and moving down to the bottom right. I
then want to threshold each ROI, then put all the ROIs together in a
stack.
I started by opening my image, then recording the following macro for
the first ROI, using Edit>Selection>Specify...
run("Specify...", "width=100 height=100 x=0 y=0");
run("Duplicate...", "title=testlargeareasquare-1.tif");
setAutoThreshold("IsoData");
//run("Threshold...");
setAutoThreshold("IsoData");
run("Convert to Mask");
This gives me a 100x100 pixel ROI from the top left corner, then
duplicates and segments it. Great. Now I tried editing the recorded
macro so that I could have it sequentially perform this on 100x100
ROIs across the whole length and height of the image with the following:
x=0;
y=0;
do {
run("Specify...", "width=100 height=100 x y");
run("Duplicate...", "title=testlargeareasquare-1.tif");
setAutoThreshold("IsoData");
//run("Threshold...");
setAutoThreshold("IsoData");
run("Convert to Mask");
x=x+100;
y=y+100;
} while (x<=1000);
while (y<=1000);
This did not work at all. It still only gives me one ROI: the first
top left.
Thank you in advance for any help you can give!!!!
Best,
Alex