# # What does each build draw in the out-of-range BAR box? # # The provoke mask localised the offending block to a 13x52 rectangle. The # question that decides whether the fix cures the operator's yellow bar is # simply: in the SEC (colour) plane, does the shipped binary light those # pixels, and do we? # import sys from PIL import Image BOX = (8, 52, 648, 531) BAR = (526, 228, 539, 280) # x0,y0,x1,y1 in cropped coords SEC = 0x003F def scan(path): im = Image.open(path).convert("RGB").crop(BOX) px = im.load() lit = 0 vals = {} for y in range(BAR[1], BAR[3]): for x in range(BAR[0], BAR[2]): r, g, b = px[x, y] wd = ((r >> 3) << 11) | ((g >> 2) << 5) | (b >> 3) v = wd & SEC if v: lit += 1 vals[v] = vals.get(v, 0) + 1 top = sorted(vals.items(), key=lambda kv: -kv[1])[:3] return lit, top for p in sys.argv[1:]: lit, top = scan(p) print("%-20s sec-lit %4d/676 top sec values: %s" % (p, lit, ", ".join("0x%02X x%d" % t for t in top)))