0

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:

  • Combine the first 2 then combine the combined image to the third stack
  • Create a macro that does the above

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");
}
Aly Abdelaziz
  • 292
  • 4
  • 24

1 Answers1

1

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");
}
Marcel
  • 502
  • 3
  • 11
  • Thanks, you confirmed by apprehension with the "No" part. I already have a batch processing Macro running. I was just trying to see if it was feasible to cut down on the processing time. – Aly Abdelaziz Dec 01 '16 at 19:16
  • 1
    Have a look at the batch mode to speed up a macro: http://imagejdocu.tudor.lu/doku.php?id=faq:macros:how_can_i_speed_up_a_macro – Marcel Dec 02 '16 at 08:58
  • Yes, i have batchmode(true); else my computer processor would have been fried a long time ago. One thing that i did notice, if you combine more then 3 images, you have to open them all then start the combine process, else it will fail to combine. – Aly Abdelaziz Dec 02 '16 at 16:11
  • Code Snippet added. – Aly Abdelaziz Dec 02 '16 at 16:14