// Macros for applying the CLAHE plugin at http://rsb.info.nih.gov/ij/plugins/clahe/index.html // by Michael Cammer March 2012 //=================================================================== // This macro operates applies a few different CLAHE paramenters to the same image and pops the // results into a stack. The paramenters are printed in the upper left of the image. To turn this off, comment out the // "drawString" line at the end of the loop. On large images, beast run on a subset of the stack. Then pick the // favorite result and run on the full image. //=================================================================== macro "iterate through CLAHE options" { original = getImageID; blocksize = newArray(7, 15, 31, 63, 127, 512); contrast = newArray(3, 7, 11, 16); for (k=0; k1) setSlice(1); run("Select All"); run("Copy"); run("Add Slice"); run("Paste"); run("Select None"); run("CLAHE ", "blocksize="+blocksize[i]+" histogram=256 maximum="+contrast[k]+""); drawString("blocksize "+blocksize[i]+", contrast "+contrast[k], 1, 30); } } // test CLAHE parameters //=================================================================== // Applies CLAHE to a stack of images. //=================================================================== macro "CLAHE on a stack" { original = getImageID; Dialog.create("CLAHE on a stack"); blocksize=127; histogramsize=256; maximum=3; Dialog.addNumber("Block size", blocksize); Dialog.addNumber("Histogram bins", histogramsize); Dialog.addNumber("Contrast max (3 to 12)", maximum); // from 3 to 12 Dialog.show(); blocksize=Dialog.getNumber(); histogramsize=Dialog.getNumber(); maximum=Dialog.getNumber(); for (i=1; i<=nSlices; i++) { selectImage(original); setSlice(i); run("CLAHE ", "blocksize="+blocksize+" histogram="+histogramsize+" maximum="+maximum+""); } // for i resetMinAndMax(); } // CLAHE on a stack //================================================================== // Applies CLAHE to all files in a directory. //================================================================== macro "run CLAHE on all files in a directory" { run("Input/Output...", "jpeg=100 gif=-1 file=.txt copy_row save_column save_row"); path = getDirectory("Choose a Directory"); filenames = getFileList(path); listArray(filenames); for (i=0; i