sclass ImageBuckets { float similarityThreshold = 0.99f; new LL buckets; int images; void addImage(RGBImage img) { new Best best; for i over buckets: { Pair p = rgbMostSimilarImage(pat, buckets.get(i), 0); best.put(i, p.b); } ++images; if (best.score() < minScore) buckets.add(ll(pat)); // new bucket else buckets.get(best!).add(pat); } }