// These macros demonstrate the use of the getStatistics() // and getRawStatistics() functions. macro "Show Statistics" { if (nSlices>1) run("Clear Results"); getVoxelSize(w, h, d, unit); n = getSliceNumber(); for (i=1; i<=nSlices; i++) { setSlice(i); getStatistics(area, mean, min, max, std); row = nResults; if (nSlices==1) setResult("Area ("+unit+"^2)", row, area); setResult("Mean ", row, mean); setResult("Std ", row, std); setResult("Min ", row, min); setResult("Max ", row, max); } setSlice(n); updateResults(); } macro "Show Raw Statistics" { if (nSlices>1) run("Clear Results"); n = getSliceNumber(); for (i=1; i<=nSlices; i++) { setSlice(i); getRawStatistics(count, mean, min, max, std); row = nResults; if (nSlices==1) setResult("Pixels", row, count); setResult("Mean ", row, mean); setResult("Std ", row, std); setResult("Min ", row, min); setResult("Max ", row, max); } setSlice(n); updateResults(); } macro "Plot Histogram" { getStatistics(area, mean, min, max, std, histogram); if (bitDepth==8 || bitDepth==24) Plot.create("Histogram", "Value", "Count", histogram); else { values = newArray(256); value = min; binWidth = (max-min)/256; for (i=0; i<256; i++) { values[i] = value; value += binWidth; } Plot.create("Histogram", "Value", "Count", values, histogram); } } macro "List Histogram Counts" { run("Clear Results"); getStatistics(area, mean, min, max, std, histogram); if (bitDepth==8 || bitDepth==24) { for (i=0; i