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).

// returns best point
static Pt bwSpiralSearch(BWImage proto, IBWImage img, double instantWinThreshold default 2) {
  float best = -1;
  long bestPt = -1;
  int leewayX = img.getWidth()-proto.getWidth();
  int leewayY = img.getHeight()-proto.getHeight();
  LongIterator it = pixelSpiral_longIterator(leewayX, leewayY);
  while (it.hasNext()) {
    long xy = it.next();
    int x = firstIntFromLong(xy), y = secondIntFromLong(xy);
    float sim = bwImageSectionsSimilarity2(img, proto, x, y, best);
    //print(x + "/" + y + ": " + sim);
    if (sim >= instantWinThreshold)
      ret longToPt(xy);
    if (sim >= best) {
      bestPt = xy;
      best = sim;
    }
  }
  ret longToPtUnlessMinus1(bestPt);
}

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: 252 / 376
Version history: 11 change(s)
Referenced in: #1006654 - Standard functions list 2 (LIVE, continuation of #761)