!7 static RGB destColor = rgb("#5650C3"); static float contrast = 5f; static float gamma = 0.5f; p-experiment { //RGBImage img = shootScreen(); RGBImage img = loadRGBImage(#1101257); int w = img.getWidth(), h = img.getHeight(); BWImage bw = new BWImage(w, h); int destColorInt = destColor.getInt(); for y to h: for x to w: { float diff = rgbDiff(img.getInt(x, y), destColorInt); //diff = pow(diff, gamma); //diff *= contrast; diff = (diff-0.2f)*10f; bw.setPixel(x, y, diff); } //showBWImage(bw); //showAutoSegmentedImage(bw); final L rects = sortRectsByMiddleY(autoSegment(bw, 2)); pnl(rects); final ImageSurface is = showImageWithSelections(bw, rects); onClick(is, voidfunc(MouseEvent e) { Pt p = is.pointFromEvent(e); pnl(rectsContaining(p, rects)); }); }