//Prompts user to select folders.... numdir = getDirectory("Select Folder Containing Numerator Image Files"); dendir = getDirectory("Select Folder Containing Denominator Image Files"); outdir = getDirectory("Select Folder For Output Images"); numlist = getFileList(numdir); denlist = getFileList(dendir); if (numlist != denlist) { print("Error: Folders must contain the same number of files"); } // ---------------------------Dialog box 1-------------------------------- Dialog.create("Create Intensity Modulated Display..."); Dialog.addCheckbox("Smooth images prior to division? ", true); Dialog.show(); smooth = Dialog.getCheckbox(); //Open the files ins the folders.... for (i=0; i blue hue = 170) run("Multiply...", "value=0.666"); // Contstrains hues from 0-170 to match calibration bar (so only red->blue colors are shown) selectWindow(denlist[i]); run("Enhance Contrast", "saturated="+usersat); // as selected by user run("8-bit"); //----------------------Creates HSB Image ------------------------------------- selectWindow(ratioimg); getDimensions(ratioimgwidth, ratioimgheight, channels, slices, frames); //Creates an HSB image... THIS IS THE ONLY WAY TO DO IT!! newImage(numlist[i]+"IMD", "RGB black", ratioimgwidth, ratioimgheight, 1); run("HSB Stack"); //Copies the ratio image into the hue channel of the HSB Stack selectWindow(ratioimg); run("Select All"); run("Copy"); run("Close"); //closes rationimg selectWindow(numlist[i]+"IMD"); setSlice(1); run("Paste"); //Creates the Saturation (constant) image newImage("Sat", "8-bit white", ratioimgwidth, ratioimgheight, 1); //Copies the Sat image into the Sat channel of the HSB Stack selectWindow("Sat"); run("Select All"); run("Copy"); run("Close"); //closes Sat image selectWindow(numlist[i]+"IMD"); setSlice(2); run("Paste"); //Copies the denominator image into the brightness channel of the HSB Stack selectWindow(denlist[i]); run("Select All"); run("Copy"); run("Close"); //closes deimg selectWindow(numlist[i]+"IMD"); setSlice(3); run("Paste"); //Turns the HSB values into an RGB image run("RGB Color"); run("Select None"); //Saves and closes selectWindow(numlist[i]+"IMD"); saveAs("tiff", outdir+numlist[i]+"IMD"); close(); } // EO process showStatus("IMD Finished!");