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

22
LINES

< > BotCompany Repo | #1005894 // bwRawImageSearchInPart

JavaX fragment (include)

1  
// similarity = e.g. 0.99f
2  
static L<FoundImg> bwRawImageSearchInPart(BWImage big, BWImage pat, Rect part, float similarity, int maxEntries) {
3  
  new L<FoundImg> found;
4  
  int wp = pat.getWidth(), hp = pat.getHeight();
5  
  int w = big.getWidth(), h = big.getHeight();
6  
  float maxError = (1f-similarity)*wp*hp;
7  
  int x2 = min(w-wp, part.x2());
8  
  int y2 = min(h-hp, part.y2());
9  
  for (int y = part.y; y < y2; y++)
10  
    for (int x = part.x; x < x2; x++) {
11  
      float diff = bwImageSectionsSimilarity(big, pat, x, y, maxError);
12  
      if (diff <= maxError) {
13  
        float sim = 1-diff/(wp*hp);
14  
        Rect r = new Rect(x, y, wp, hp);
15  
        found.add(new FoundImg(r, sim));
16  
        ping();
17  
        if (l(found) >= maxEntries) ret found;
18  
        x += wp-1;
19  
      }
20  
    }
21  
  ret found;
22  
}

Author comment

Began life as a copy of #1005396

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: #1005894
Snippet name: bwRawImageSearchInPart
Eternal ID of this version: #1005894/1
Text MD5: f7d53ecca67c6bba59d101d7cff8cd26
Author: stefan
Category: javax / imaging
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2016-12-12 14:34:12
Source code size: 798 bytes / 22 lines
Pitched / IR pitched: No / No
Views / Downloads: 453 / 489
Referenced in: [show references]