static L uniqueBrightnessesInBWImage(IBWImage img) { if (img == null) null; new BitSet bs; int w = img.getWidth(), h = img.getHeight(); for y to h: for x to w: uniqueColorsInBWImage.set(img.getInt(x, y)); ret bitCount(bs); }