//File contains both macros for percentile values and all pixel value output //This macro finds measurements and the 20th, 50th, and 80th //percentile pixel values for a region of interest. //It appends the information to the results table and //creates a file to store the information. macro "getPercentiles [f1]"{ requires("1.42j"); run("8-bit"); getHistogram (values, counts, 256); position = 0; j=0; temp=0; v=0; i=0; //find the total number of counts to make a larger array count_total = 0; for (v=0; v < counts.length; v++){ count_total = count_total + counts[v]; } print(count_total); a = newArray(count_total); for(j=0; j < values.length; j++){ count_local = counts[j]; while(temp < count_local){ a[position] = values[j]; position++; temp++; } temp = 0; } Array.sort(a); twenty = a.length*0.2 + 0.5; twenty = -floor(-twenty); fifty = a.length*0.5; fifty = -floor(-fifty); eighty = a.length*0.8 + 0.5; eighty = -floor(-eighty); run("Measure"); currentRow = nResults - 1; setResult("20th percentile", currentRow, a[twenty]); setResult("50th percentile", currentRow, a[fifty]); setResult("80th percentile", currentRow, a[eighty]); updateResults; path = getDirectory("home") + "testvalues.xls"; saveAs("Results", path); }