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

13
LINES

< > TinyBrain | #1005919 - bwImageSectionsSimilarity2

JavaX fragment (include)

// works in similarity
static float bwImageSectionsSimilarity2(BWImage big, BWImage pat, int x, int y, float similarity) {
  int wp = pat.getWidth(), hp = pat.getHeight();
  int w = big.getWidth(), h = big.getHeight();
  float maxError = (1f-similarity)*wp*hp;
  float diff = 0;
  for (int yy = 0; yy < hp; yy++)
    for (int xx = 0; xx < wp; xx++) {
      diff += Math.abs(big.getPixel(x+xx, y+yy)-pat.getPixel(xx, yy));
      if (diff > maxError) ret similarity-0.001f;
    }
  ret 1f-diff/wp/hp;
}

Author comment

Began life as a copy of #1005394

download  show line numbers  debug dex   

Travelled to 5 computer(s): cfunsshuasjs, gwrvuhgaqvyk, mqqgnosmbjvj, sawdedvomwva, tvejysmllsmz

No comments. add comment

Snippet ID: #1005919
Snippet name: bwImageSectionsSimilarity2
Eternal ID of this version: #1005919/1
Text MD5: a21859d38ccc30b63e629909884dae60
Author: stefan
Category: javax / imaging
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2016-12-12 18:40:54
Source code size: 512 bytes / 13 lines
Pitched / IR pitched: No / No
Views / Downloads: 124 / 111
Referenced in: [show]