static float bwSimpleContrastValue(BWImage bw) { if (bw == null) ret 0f; int w = bw.getWidth(), h = bw.getHeight(); float min = 1, max = 0; for y to h: for x to w: { float f = bw.getPixel(x, y); max = max(max, f); min = min(min, f); } ret max-min; }