Warning: session_start(): open(/var/lib/php/sessions/sess_r9i3tg2kicht64n94p6pm7co5i, O_RDWR) failed: No space left on device (28) in /var/www/tb-usercake/models/config.php on line 51
Warning: session_start(): Failed to read session data: files (path: /var/lib/php/sessions) in /var/www/tb-usercake/models/config.php on line 51
static BWImage bwAutoContrast(BWImage bw) {
ret bwAutoContrast(bw, 0f);
}
// def value is usually irrelevant
static BWImage bwAutoContrast(BWImage bw, float def) {
if (bw == null) null;
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);
min = min(min, f);
max = max(max, f);
}
if (min == max) ret new BWImage(w, h, def);
if (min == 0 && max == 1) ret bw;
float factor = floatRatio(1, max-min);
BWImage bw2 = new BWImage(w, h);
for y to h: for x to w:
bw2.setPixel(x, y, (bw.getPixel(x, y)-min)*factor);
ret bw2;
}