Aly Abdelaziz
Aly Abdelaziz

Reputation: 290

Combine 3 Stacks in ImageJ

Is there a way to "Stack Combine" 3 stacks side by side.

Image>Stacks>Tools>Combine

Supports the combination of 2 stacks, side by side. The two ways around this:

run("Combine...", "stack1=STAC1_NAME stack2=STACK2_NAME"); run("Combine...", "stack1=[Combined Stacks] stack2=STACK3_NAME");

Is there another way to do this, since, for example combining 20 stacks side-by-side.

Code Snippet added/

//Specify Folders here//
output = "PATH";
combined = "PATH";
original= "PATH";

//Batch Mode for ImageJ
setBatchMode(true); 
list = getFileList(input);
for (i = 0; i < list.length; i++) {
        combine(original, output, combined, list[i]);
}
setBatchMode(false);
function combine(original, output, combined, filename) {
//Open Outline & Overlay for Combine Stack//
name_outline = filename + "_outline.png";
name_overlay = filename + "_overlay.png";
name_ellipse = filename + "_ellipse.png";
name_original = replace(filename, "_watershed.tif", ".tif");
open(original + name_original);
run("RGB Color");
open(output + name_overlay);
run("RGB Color");
open(output + name_outline);
run("RGB Color");
open(output + name_ellipse);
run("RGB Color");
run("Combine...", "stack1=filename stack2=name_overlay");
rename("combinedstack01");
run("Combine...", "stack1=name_outline stack2=name_ellipse");
rename("combinedstack02");
run("Combine...", "stack1=combinedstack01 stack2=combinedstack02");
saveAs("PNG", combined + filename + "_comb.png");
run("Close All");
}

Upvotes: 0

Views: 1809

Answers (1)

Marcel
Marcel

Reputation: 522

According to the documentation, no:

http://imagej.net/Stack_Manipulation

http://imagej.net/Stack-slice_Manipulations

However you can easily batch process a whole stack folder with the combine method, see:

http://imagej.net/Batch_Processing

Here an example macro

E.g.(adjust the paths! - stacks are named for this script 'stack1', 'stack2',....):

input = "C:\\Users\\test\\Pictures\\combine";
open("C:\\Users\\test\\Pictures\\combine\\stack1.tif");
rename("combinedStack");
list = getFileList(input);
for (i = 1; i < list.length; i++){
  open(list[i]);
  title=getTitle();
  run("Combine...", "stack1="+title+" stack2=combinedStack");
  rename("combinedStack");
}

Upvotes: 1

Related Questions