static L<Rect> areasColored(Color color) { ret areasColored(shootScreen(), color); } static int areasColored_g = 3; static L<Rect> areasColored(RGBImage img, int color) { ret areasColored(img, new Color(color)); } static L<Rect> areasColored(RGBImage img, Color color) { ret areasColored(img, color, areasColored_g); } static L<Rect> areasColored(RGBImage img, Color color, int g) { int w = img.w(), h = img.h(); int gw = w/g, gh = h/g; new BitSet grid; int intColor = color.getRGB() & 0xFFFFFF; int overlap = 0; for (int gy = 0; gy <= h- g; gy += g) next: for (int gx = 0; gx <= w- g; gx += g) { float min = 1, max = 0; int y2 = min(h, gy + g + overlap); int x2 = min(w, gx + g + overlap); if (rgbAllPixelsInAreaEqualTo(img, gx, gy, x2, y2, intColor)) grid.set((gy / g) * gw + (gx / g)); } L<Rect> clips = floodFillGrid(grid, gw, gh, g); //print(n(clips, "areas") + " found for color " + new RGB(color) + ": " + struct(clips)); ret clips; }
Began life as a copy of #1006211
download show line numbers debug dex old transpilations
Travelled to 14 computer(s): aoiabmzegqzx, bhatertpkbcr, cbybwowwnfue, cfunsshuasjs, gwrvuhgaqvyk, ishqpsrjomds, lpdgvwnxivlt, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, sawdedvomwva, tslmcundralx, tvejysmllsmz, vouqrxazstgt
No comments. add comment
Snippet ID: | #1006215 |
Snippet name: | areasColored |
Eternal ID of this version: | #1006215/1 |
Text MD5: | 2792aa382e7053f1455aa54052491b73 |
Author: | stefan |
Category: | javax / ocr |
Type: | JavaX fragment (include) |
Public (visible to everyone): | Yes |
Archived (hidden from active list): | No |
Created/modified: | 2016-12-29 16:53:51 |
Source code size: | 1048 bytes / 35 lines |
Pitched / IR pitched: | No / No |
Views / Downloads: | 535 / 550 |
Referenced in: | [show references] |