Not logged in.  Login/Logout/Register | List snippets | | Create snippet | Upload image | Upload data

16
LINES

< > BotCompany Repo | #1020127 // rgbImageSimilarity_sameSize

JavaX fragment (include)

// returns similarity (not diff)
static float rgbImageSimilarity_sameSize(RGBImage a, RGBImage b, float similarity) {
  int w = a.w(), h = a.h();
  if (w != b.w() || h != b.h()) fail("not same size");
  float factor = w*h;
  float maxError = (1f-similarity)*factor;
  float diff = 0;
  for (int y = 0; y < h; y++)
    for (int x = 0; x < w; x++) {
      diff += rgbDiff(
        a.getInt(x, y),
        b.getInt(x, y));
      if (diff > maxError) ret similarity-0.001f;
    }
  ret 1f-diff/factor;
}

Author comment

Began life as a copy of #1006762

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: #1020127
Snippet name: rgbImageSimilarity_sameSize
Eternal ID of this version: #1020127/4
Text MD5: c6fd9a8c8a4a05b964fc86a2f99bbfd0
Author: stefan
Category: javax / ocr
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2018-12-08 22:15:47
Source code size: 514 bytes / 16 lines
Pitched / IR pitched: No / No
Views / Downloads: 299 / 326
Version history: 3 change(s)
Referenced in: [show references]