static L listOfBrightestPixels(BWImage img) { int w = img.getWidth(), h = img.getHeight(); new LPair l; for y to h: for x to w: l.add(pair(pt(x, y), img.getInt(x, y)); ret pairsA(sortBySecondOfPairsDesc_inPlace(l)); } static L listOfBrightestPixels(int n, BWImage img) { ret takeFirst(n, listOfBrightestPixels(img)); }