1 | sclass ImageBuckets { |
2 | float similarityThreshold = 0.99f; |
3 | new LL<RGBImage> buckets; |
4 | new Map<Int> duplicates; |
5 | int images, totalDuplicates; |
6 | |
7 | void addImage(RGBImage pat) { |
8 | new Best<Int> best; |
9 | for i over buckets: { |
10 | Pair<RGBImage, Float> p = rgbMostSimilarImage(pat, buckets.get(i), 0); |
11 | best.put(i, p.b); |
12 | if (p.b == 1) { // it's a duplicate |
13 | ++images; |
14 | ++totalDuplicates; |
15 | duplicates.put(i, toInt(duplicates.get(i))+1); |
16 | ret; |
17 | } |
18 | } |
19 | ++images; |
20 | if (best.score() < similarityThreshold) |
21 | buckets.add(ll(pat)); // new bucket |
22 | else |
23 | buckets.get(best!).add(pat); |
24 | } |
25 | } |
Began life as a copy of #1020130
download show line numbers debug dex old transpilations
Travelled to 8 computer(s): bhatertpkbcr, cfunsshuasjs, gwrvuhgaqvyk, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tvejysmllsmz, vouqrxazstgt
No comments. add comment
Snippet ID: | #1020188 |
Snippet name: | ImageBuckets |
Eternal ID of this version: | #1020188/6 |
Text MD5: | bab2477a2eee619addbfcf453111c455 |
Author: | stefan |
Category: | javax / image recognition |
Type: | JavaX fragment (include) |
Public (visible to everyone): | Yes |
Archived (hidden from active list): | No |
Created/modified: | 2018-12-09 21:55:18 |
Source code size: | 673 bytes / 25 lines |
Pitched / IR pitched: | No / No |
Views / Downloads: | 380 / 880 |
Version history: | 5 change(s) |
Referenced in: | [show references] |