Libraryless. Click here for Pure Java version (2598L/16K).
1 | static float bwImageSimilarityResized_ignoreRatioMismatch(BWImage a, BWImage b, double similarityRequired) { |
2 | int aw = a.w(), ah = a.h(); |
3 | int bw = b.w(), bh = b.h(); |
4 | int wp = max(aw, bw), hp = max(ah, bh); |
5 | float ratio1 = ((float) aw)/ah, ratio2 = ((float) bw)/bh; |
6 | float factor = wp*hp; |
7 | float maxError = (1f-(float) similarityRequired)*factor; |
8 | float diff = 0; |
9 | for (int y = 0; y < hp; y++) |
10 | for (int x = 0; x < wp; x++) { |
11 | diff += Math.abs( |
12 | a.getPixel(x*aw/wp, y*ah/hp)- |
13 | b.getPixel(x*bw/wp, y*bh/hp)); |
14 | if (diff > maxError) ret (float) similarityRequired-0.001f; |
15 | } |
16 | ret 1f-diff/factor; |
17 | } |
Began life as a copy of #1006195
download show line numbers debug dex old transpilations
Travelled to 13 computer(s): aoiabmzegqzx, bhatertpkbcr, cbybwowwnfue, cfunsshuasjs, gwrvuhgaqvyk, irmadwmeruwu, ishqpsrjomds, lpdgvwnxivlt, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tvejysmllsmz, vouqrxazstgt
No comments. add comment
Snippet ID: | #1018643 |
Snippet name: | bwImageSimilarityResized_ignoreRatioMismatch |
Eternal ID of this version: | #1018643/4 |
Text MD5: | 17583baf3a52161cbd1c12e25543c866 |
Transpilation MD5: | 1a431c138a90fb93e5567e25e6a4ef34 |
Author: | stefan |
Category: | javax / ocr |
Type: | JavaX fragment (include) |
Public (visible to everyone): | Yes |
Archived (hidden from active list): | No |
Created/modified: | 2019-08-23 19:52:24 |
Source code size: | 650 bytes / 17 lines |
Pitched / IR pitched: | No / No |
Views / Downloads: | 283 / 384 |
Version history: | 3 change(s) |
Referenced in: | [show references] |