import ij.plugin.*; import ij.*; import ij.process.*; import ij.gui.*; public class RGB_Stack_Merge implements PlugIn { private ImagePlus imp; private byte[] blank; /** Merges one, two or three 8-bit or RGB stacks into a single RGB stack. */ public void run(String arg) { imp = WindowManager.getCurrentImage(); mergeStacks(); } /** Combines three grayscale stacks into one RGB stack. */ public void mergeStacks() { int[] wList = WindowManager.getIDList(); if (wList==null) { IJ.error("No images are open."); return; } String[] titles = new String[wList.length+1]; for (int i=0; i2?titles[2]:none; gd.addChoice("Blue:", titles, title3); gd.addCheckbox("Keep source images", false); gd.showDialog(); if (gd.wasCanceled()) return; int[] index = new int[3]; index[0] = gd.getNextChoiceIndex(); index[1] = gd.getNextChoiceIndex(); index[2] = gd.getNextChoiceIndex(); boolean keep = gd.getNextBoolean(); ImagePlus[] image = new ImagePlus[3]; int stackSize = 0; int width = 0; int height = 0; for (int i=0; i<3; i++) { if (index[i]