// Demonstrate the use of the getHistogram and graph functions requires("1.30h"); bins = 256; getHistogram(values, counts, bins); is8bits = bitDepth()==8 || bitDepth()==24; graph("Histogram", values, counts, "Pixel Value", "Count"); selectWindow("Histogram"); x = 70; y = 40; n = 0; sum = 0; min = 9999999; max = -9999999; for (i=0; i0) { n += count; sum += count*i; if (imax) max = i; } } draw("Pixel Count: "+n); if (is8bits) { if (counts[0]>0 || counts[255]>0) { draw("Black Pixels: "+counts[0]+" ("+counts[0]*100/n+"%)"); draw("White Pixels: "+counts[255]+" ("+counts[255]*100/n+"%)"); } draw("Mean: "+sum/n); draw("Min: "+min); draw("Max: "+max); } function draw(text) { drawString(text, x, y); for (i=0; i<15; i++) y++; }