// "Batch RGB Merge" // Opens multiple sets of three separate color channels as // an RGB stack or converts them to RGB images. File names // ending in "d1", "d2" and "d0" are assumed to be red, green // and blue channels respectively, but this can be changed in // the dialog box. // A sample image set, courtesy of Mikael Bjorklund, is available at: // http://rsb.info.nih.gov/ij/macros/images/DrosophilaCells.zip // It consists of three images of Drosophila S2 cells, // each with three channels (d0=blue, d1=red and d2=green // as indicated by the end of the filename. The staining is // standard Hoechst, phalloidin, tubulin. Dialog.create("RGB Batch Convert"); Dialog.addString("Red Suffix:", "d1"); Dialog.addString("Green Suffix:", "d2"); Dialog.addString("Blue Suffix:", "d0"); Dialog.addCheckbox("Open as Stack", true); Dialog.show(); redSuffix = Dialog.getString() + "."; greenSuffix = Dialog.getString() + "."; blueSuffix = Dialog.getString() + "."; openAsStack = Dialog.getCheckbox(); if (openAsStack) openImagesAsStack(); else batchConvert(); exit; function openImagesAsStack() { dir = getDirectory("Choose Source Directory "); list = getFileList(dir); setBatchMode(true); n = list.length; if ((n%3)!=0) exit("The number of files must be a multiple of 3"); stack = 0; first = 0; for (i=0; i