// Demonstrate the use of the getHistogram and Plot.create functions requires("1.31l"); bins = 256; getHistogram(values, counts, bins); is8bits = bitDepth()==8 || bitDepth()==24; Plot.create("Histogram", "Pixel Value", "Count", values, counts); n = 0; sum = 0; min = 9999999; max = -9999999; for (i=0; i0) { n += count; sum += count*i; if (imax) max = i; } } var x=0.025, y=0.1; // global variables 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) { Plot.addText(text, x, y); y += 0.08; }