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

19
LINES

< > BotCompany Repo | #1005753 // bwImagesSimilar

JavaX fragment (include)

1  
static float bwImagesSimilar_similarity = 0.99f;
2  
3  
static bool bwImagesSimilar(BWImage big, BWImage pat) {
4  
  ret bwImagesSimilar(big, pat, bwImagesSimilar_similarity);
5  
}
6  
7  
static bool bwImagesSimilar(BWImage big, BWImage pat, float similarity) {
8  
  int wp = pat.getWidth(), hp = pat.getHeight();
9  
  int w = big.getWidth(), h = big.getHeight();
10  
  if (wp != w || hp != h) false;
11  
  float max = (1f-similarity)*wp*hp;
12  
  float diff = 0;
13  
  for (int yy = 0; yy < hp; yy++)
14  
    for (int xx = 0; xx < wp; xx++) {
15  
      diff += Math.abs(big.getPixel(xx, yy)-pat.getPixel(xx, yy));
16  
      if (diff > max) false;
17  
    }
18  
  true;
19  
}

Author comment

Began life as a copy of #1005394

download  show line numbers  debug dex  old transpilations   

Travelled to 14 computer(s): aoiabmzegqzx, bhatertpkbcr, cbybwowwnfue, cfunsshuasjs, ddnzoavkxhuk, gwrvuhgaqvyk, ishqpsrjomds, lpdgvwnxivlt, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tslmcundralx, tvejysmllsmz, vouqrxazstgt

No comments. add comment

Snippet ID: #1005753
Snippet name: bwImagesSimilar
Eternal ID of this version: #1005753/1
Text MD5: 9c2b848ecedeb8a283defe4ddcdacffb
Author: stefan
Category: javax / imaging
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2016-12-09 01:45:45
Source code size: 629 bytes / 19 lines
Pitched / IR pitched: No / No
Views / Downloads: 639 / 650
Referenced in: [show references]