!7 p { RGBImage a = loadRGBImage(#1006818), b = loadRGBImage(#1006819); compare(a, b); } svoid compare(RGBImage a, RGBImage b) { //new HashSet deltas; new Best best; repeat { Rect r = randomScreenRect(50, 50); RGBImage clip = a.clip(r); if (rgbInnerPrecision(clip) >= 0.5f) { Rect r2 = rgbSearchPrecise(b, clip); if (r2 != null && neq(r, r2)) { Pt delta = new Pt(r2.x-r.x, r2.y-r.y); Rect match = expandMatch(a, b, r, r2); if (best.put(match, match.w*match.h)) { print("New best. Movement: " + delta + ". Match size: " + match.w + "/" + match.h); quickShowImage(rgbScale(a.clip(match), 1)); } } } } } static Rect expandMatch(RGBImage a, RGBImage b, Rect r1, Rect r2) { assertEquals(r1.w, r2.w); assertEquals(r1.h, r2.h); print("Comparing " + r1 + " and " + r2); repeat { Rect r = r1; if (r2.x > 0 && r1.x > 0 && rgbImageSectionsIdentical(a, new Rect(r1.x-1, r1.y, 1, r1.h), b, new Rect(r2.x-1, r2.y, 1, r2.h))) { r1 = growRectLeft(r1, 1); r2 = growRectLeft(r2, 1); } if (eq(r, r1)) break; } ret r1; }