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

21
LINES

< > BotCompany Repo | #1029762 // bwSpiralSearch [OK]

JavaX fragment (include) [tags: use-pretranspiled]

Libraryless. Click here for Pure Java version (5391L/35K).

1  
// returns best point
2  
static Pt bwSpiralSearch(BWImage proto, IBWImage img, double instantWinThreshold default 2) {
3  
  float best = -1;
4  
  long bestPt = -1;
5  
  int leewayX = img.getWidth()-proto.getWidth();
6  
  int leewayY = img.getHeight()-proto.getHeight();
7  
  LongIterator it = pixelSpiral_longIterator(leewayX, leewayY);
8  
  while (it.hasNext()) {
9  
    long xy = it.next();
10  
    int x = firstIntFromLong(xy), y = secondIntFromLong(xy);
11  
    float sim = bwImageSectionsSimilarity2(img, proto, x, y, best);
12  
    //print(x + "/" + y + ": " + sim);
13  
    if (sim >= instantWinThreshold)
14  
      ret longToPt(xy);
15  
    if (sim >= best) {
16  
      bestPt = xy;
17  
      best = sim;
18  
    }
19  
  }
20  
  ret longToPtUnlessMinus1(bestPt);
21  
}

download  show line numbers  debug dex  old transpilations   

Travelled to 6 computer(s): bhatertpkbcr, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tvejysmllsmz, vouqrxazstgt

No comments. add comment

Snippet ID: #1029762
Snippet name: bwSpiralSearch [OK]
Eternal ID of this version: #1029762/12
Text MD5: 914b6e2727c7449fde0f06847fabbf7c
Transpilation MD5: e0fa0e43e5f802a82a6b7a6b65c748ac
Author: stefan
Category: javax
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2020-09-12 02:36:25
Source code size: 724 bytes / 21 lines
Pitched / IR pitched: No / No
Views / Downloads: 251 / 376
Version history: 11 change(s)
Referenced in: [show references]