static BWImage img_cubedDistanceFromColor_withGain(RGBImage img, RGB color, double gain) { int w = img.getWidth(), h = img.getHeight(); int col = color.getInt(); BWImage bw = new(w, h); for y to h: for x to w: bw.setPixel(x, y, pow(rgbDiff(img.getInt(x, y), col)*(float) gain, 3)); ret bw; } static BWImage img_cubedDistanceFromColor_withGain(BufferedImage img, RGB color, double gain) { ret img_cubedDistanceFromColor_withGain(RGBImage(img), color, gain); } static BWImage img_cubedDistanceFromColor_withGain(RGB color, double gain, BufferedImage img) { ret img_cubedDistanceFromColor_withGain(img, color, gain); }