// returns pairs (col332 [0-255], percentage of image) static LPair dominant332colorsWithPercentage(RGBImage img) { int[] array = histogram332_array(img); new MultiSet ms; int total = 0; for i over array: { int x = array[i]; ms.add(i, x); total += x; } double total2 = total /= 100; ret map(ms.highestFirst(), col -> pair(col, doubleRatio(ms.get(col), total2))); } static LPair dominant332colorsWithPercentage(BufferedImage img) { ret dominant332colorsWithPercentage(RGBImage(img)); }