// contrast=1 => original // contrast=2 => twice as contrasty // contrast=.5 => half as contrasty static BWImage bwContrast(double contrast, BWImage bw) { if (contrast == 1 || bw == null) ret bw; int w = bw.getWidth(), h = bw.getHeight(); BWImage bw2 = new BWImage(w, h); for y to h: for x to w: bw2.setPixel(x, y, (float) (0.5+(bw.getPixel(x, y)-0.5)*contrast)); ret bw2; }