Not logged in.  Login/Logout/Register | List snippets | | Create snippet | Upload image | Upload data

35
LINES

< > BotCompany Repo | #1006215 // areasColored

JavaX fragment (include)

1  
static L<Rect> areasColored(Color color) {
2  
  ret areasColored(shootScreen(), color);
3  
}
4  
5  
static int areasColored_g = 3;
6  
7  
static L<Rect> areasColored(RGBImage img, int color) {
8  
  ret areasColored(img, new Color(color));
9  
}
10  
11  
static L<Rect> areasColored(RGBImage img, Color color) {
12  
  ret areasColored(img, color, areasColored_g);
13  
}
14  
15  
static L<Rect> areasColored(RGBImage img, Color color, int g) {
16  
  int w = img.w(), h = img.h();
17  
  int gw = w/g, gh = h/g;
18  
19  
  new BitSet grid;
20  
  int intColor = color.getRGB() & 0xFFFFFF;
21  
  int overlap = 0;
22  
23  
  for (int gy = 0; gy <= h- g; gy += g)
24  
    next: for (int gx = 0; gx <= w- g; gx += g) {
25  
      float min = 1, max = 0;
26  
      int y2 = min(h, gy + g + overlap);
27  
      int x2 = min(w, gx + g + overlap);
28  
      if (rgbAllPixelsInAreaEqualTo(img, gx, gy, x2, y2, intColor))
29  
        grid.set((gy / g) * gw + (gx / g));
30  
    }
31  
32  
  L<Rect> clips = floodFillGrid(grid, gw, gh, g);
33  
  //print(n(clips, "areas") + " found for color " + new RGB(color) + ": " + struct(clips));
34  
  ret clips;
35  
}

Author comment

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: 476 / 487
Referenced in: [show references]