static int[] 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: bs.set(img.getInt(x, y)); ret bitSetToIntArray(bs); }