macro "Background Corrected Density [F12]" { // Written by Paul Werten and Wayne Rasband (10.03.2005) // // This macro uses the points along the selection boundary to calculate the // background of the selection, and then uses this value to calculate the // background-corrected integrated density. Size and shape of the selection // may be changed at any time during the measurements. To obtain meaningful // results, background values should be smaller than the actual data values // (i.e., the background should appear dark, while data should be light). It // may therefore be necessary to invert the image before analyzing it. Also, // for the macro to work, "Area" and "Mean" must first be selected in the // "Analyze / Set Measurements" menu option. To actually measure, make an // appropriate selection and use F12 to get the results. requires('1.34h'); if (selectionType==-1) exit("Selection required"); run("Measure"); mean=getResult('Mean',nResults-1); stddev=getResult('StdDev',nResults-1); background=stddev*3.5 + mean; if (isNaN(mean)) exit("StdDev and Mean must be be selected in Analyze>Set Measurements"); setResult('Background',nResults-1,background); updateResults(); print('The value of background: ', background); run("Select None"); setThreshold(0,background,'red'); run("Threshold..."); } -- ImageJ mailing list: http://imagej.nih.gov/ij/list.html