Re: Concatenate bug in macro
Posted by
Rasband, Wayne (NIH/NIMH) [E] on
URL: http://imagej.273.s1.nabble.com/Concatenate-bug-in-macro-tp5011685p5011715.html
On Feb 19, 2015, at 8:29 AM, Djoere Gaublomme <
[hidden email]> wrote:
>
> Hello,
>
> In a macro, I am trying to create an image stack with 10 identical slices (based on 1 non-z-stack image).
> Since I don't know a very elegant solution to this problem, I am using the concatenate function from the stack tools, with the same image as the input 10 times.
> Although this works most of the time, sometimes the number of slices included in the resulting stack is too little when running the macro. I am wondering how this inconsistency can be fixed.
The Image>Stacks>Tools>Concatenate command was not designed to create stacks of identical slices. Instead, use a batch mode loop, something like
size = 50;
setBatchMode(true);
run("Boats (356K)");
stack = getImageID()
for (i=1; i<size; i++) {
run("Duplicate...", "title=temp");
run("Copy");
selectImage(stack);
run("Add Slice");
run("Paste");
}
setSlice(1);
run("Select None");
setBatchMode(false);
In JavaScript and Java, use code something like
size = 50;
img = IJ.openImage("
http://imagej.nih.gov/ij/images/boats.gif");
ip = img.getProcessor();
stack = new ImageStack(ip.getWidth(),ip.getHeight());
for (i=0; i<size; i++)
stack.addSlice(ip.duplicate());
img.setStack(stack);
img.show();
-wayne
> Code:
> run("Concatenate...", " title=10x-ondersteFilled keep image1=ondersteFilled image2=ondersteFilled image3=ondersteFilled image4=ondersteFilled image5=ondersteFilled image6=ondersteFilled image7=ondersteFilled image8=ondersteFilled image9=ondersteFilled image10=ondersteFilled image11=[-- None --]");
>
>
> Thanks in advance
>
> Djoere
--
ImageJ mailing list:
http://imagej.nih.gov/ij/list.html