sbool bwImageSearch_best_verbose;
static FoundImg bwImageSearch_best(BWImage big, BWImage pat, float similarity) {
new Best<Rect> best;
int wp = pat.getWidth(), hp = pat.getHeight();
int w = big.getWidth(), h = big.getHeight();
float maxError = (1f-similarity)*wp*hp;
bigloop: for (int y = 0; y < h-hp; y++)
for (int x = 0; x < w-wp; x++) {
float diff = bwImageSectionsSimilarity(big, pat, x, y, maxError);
if (diff <= maxError && best.isNewBest(-diff)) {
maxError = diff;
if (bwImageSearch_best_verbose) {
float sim = 1-diff/(wp*hp);
print(" Image found at " + x + "/" + y + " [sim: " + formatDouble(sim, 4) + "]");
}
Rect r = new Rect(x, y, wp, hp);
best.put(r, -diff);
ping();
if (diff == 0) break bigloop;
}
}
Rect r = best.get();
ret r == null ? null : new FoundImg(r, 1-(-(float) best.bestScore())/(wp*hp));
}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: | #1006412 |
| Snippet name: | bwImageSearch_best - return best match |
| Eternal ID of this version: | #1006412/1 |
| Text MD5: | 951043bdef24465a6d885ea68d6c5d37 |
| Author: | stefan |
| Category: | javax / imaging |
| Type: | JavaX fragment (include) |
| Public (visible to everyone): | Yes |
| Archived (hidden from active list): | No |
| Created/modified: | 2017-01-01 19:10:27 |
| Source code size: | 957 bytes / 25 lines |
| Pitched / IR pitched: | No / No |
| Views / Downloads: | 1000 / 1002 |
| Referenced in: | #1006654 - Standard functions list 2 (LIVE, continuation of #761) #1019535 - rgbImageSearch_best - return best match #1022979 - bwImageSearch_best_virtualBig - return best match #1027280 - bwImageSearch_onFound |