We are curious about an inconsistent result we are getting with auto threshold.
We have stacks of between 100 and 400 images that we want to autothreshold. We are using the following commands within a loop (full macro below). setAutoThreshold("Default"); run("Convert to Mask", "calculate black"); // autothresholds each slice But we are getting inconsistent results. For instance, slices 68 and 69 from one of the stacks pictured here http://www.flickr.com/photos/mcammer/8000381079/ come out with reversed results pictured here http://www.flickr.com/photos/mcammer/8000382290/ We could write a macro to flip the contrast automatically based on the histogram distributions, but shouldn't the result be consistent to begin with? Thank you! ============= macro "Prepare LSM IRM for Volocity tracking" { run("32-bit"); run("Bandpass Filter...", "filter_large=160 filter_small=0 suppress=None tolerance=5 process"); run("Select All"); floatStack(); CLAHEstack(127, 256, 3); run("Median...", "radius=2 stack"); setAutoThreshold("Default"); run("Convert to Mask", "calculate black"); // autothresholds each slice run("Erode", "stack"); run("Dilate", "stack"); } // end "Prepare LSM IRM for Volocity tracking" //=========================================================================== //Kenton Arkill [[hidden email]] //Floating means that each image has the same mean pixel value and the same standard deviation. //I find it really useful as it means the same threshold can often be used on all the images. Here is my macro, //it floats the stack to the values of the first slice (so make sure it is a good image): function floatStack() { run("32-bit"); setSlice(1); getRawStatistics(nPixels, meanref, min, max, stdref, histogram); for (i = 1; i <= nSlices; i++) { setSlice(i); getRawStatistics(nPixels, meani, min, max, stdi, histogram); run("Subtract...", "value="+meani+" slice"); run("Divide...", "value="+stdi+" slice"); run("Multiply...", "value="+stdref+" slice"); run("Add...", "value="+stdref+" slice"); } run("Enhance Contrast", "saturated=0.35"); setSlice(1); } // end floatStack() //=================================================================== // Applies CLAHE to a stack of images. //=================================================================== function CLAHEstack(blocksize, histogramsize, maximum) { original = getImageID; for (i=1; i<=nSlices; i++) { selectImage(original); setSlice(i); run("CLAHE ", "blocksize="+blocksize+" histogram="+histogramsize+" maximum="+maximum); } // for i resetMinAndMax(); } // end CLAHEstack() ________________________________________________________ Michael Cammer, Assistant Research Scientist Skirball Institute of Biomolecular Medicine Lab: (212) 263-3208 Cell: (914) 309-3270 -- ImageJ mailing list: http://imagej.nih.gov/ij/list.html |
Free forum by Nabble | Edit this page |