macro "Apply LUTs Folder" { // Use the AuPbSn image if none is open if (nImages == 0) { run("AuPbSn 40"); } getDimensions(width, height, channels, slices, frames); inTitle = getTitle(); inID = getImageID(); // Folder chooser defaulting at the root of the LUTs menu oridir = File.getDefaultDir; rootdir = getDir("imagej"); startdir = rootdir + "scripts" + File.separator + "LUTs" + File.separator + "___Grays_.ijm"; File.setDefaultDir(startdir); lutdir = getDir("Choose folder in the LUTs menu"); File.setDefaultDir(oridir); setBatchMode(true); // Count all LUT-calling files and create the output stack count = 0; countFiles(lutdir); newImage(inTitle + "-LUTs", "RGB black", width, height, count); outID = getImageID(); l=0; processFiles(lutdir); run("Select None"); setSlice(1); setBatchMode("exit and display"); } function countFiles(dir) { list = getFileList(dir); for (i=0; i