1 | sbool bwImageSearch_best_verbose; |
2 | |
3 | static FoundImg bwImageSearch_best(BWImage big, BWImage pat, float similarity) {
|
4 | new Best<Rect> best; |
5 | int wp = pat.getWidth(), hp = pat.getHeight(); |
6 | int w = big.getWidth(), h = big.getHeight(); |
7 | float maxError = (1f-similarity)*wp*hp; |
8 | bigloop: for (int y = 0; y < h-hp; y++) |
9 | for (int x = 0; x < w-wp; x++) {
|
10 | float diff = bwImageSectionsSimilarity(big, pat, x, y, maxError); |
11 | if (diff <= maxError && best.isNewBest(-diff)) {
|
12 | maxError = diff; |
13 | if (bwImageSearch_best_verbose) {
|
14 | float sim = 1-diff/(wp*hp); |
15 | print(" Image found at " + x + "/" + y + " [sim: " + formatDouble(sim, 4) + "]");
|
16 | } |
17 | Rect r = new Rect(x, y, wp, hp); |
18 | best.put(r, -diff); |
19 | ping(); |
20 | if (diff == 0) break bigloop; |
21 | } |
22 | } |
23 | Rect r = best.get(); |
24 | ret r == null ? null : new FoundImg(r, 1-(-(float) best.bestScore())/(wp*hp)); |
25 | } |
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: | 755 / 783 |
| Referenced in: | [show references] |