static BWImage colorPredicateToBWImage(F1 predicate, RGBImage img) { int w = img.getWidth(), h = img.getHeight(); BWImage bw = new(w, h); for y to h: for x to w: if (callF(predicate, img.getInt(x, y))) bw.setPixel(x, y, 1f); ret bw; }