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

25
LINES

< > BotCompany Repo | #1035864 // preciseAverageOfBinaryImages (backup)

JavaX fragment (include)

// images must have same size
static FloatBWImage preciseAverageOfBinaryImages(L<? extends IBinaryImage> l) {
  int n = l(l);
  if (n == 0) null;
  var it = iterator(l);
  var img = it.next();
  int w = img.getWidth(), h = img.getHeight();
  int[] pixels = new[w*h];
  while true {
    int i = 0;
    for y to h:
      for x to w: {
        if (img.getBoolPixel(x, y))
          pixels[i]++;
        i++;
      }
    if (!it.hasNext()) break;
    img = it.next();
  }
  float[] floats = new[w*h];
  double factor = 1.0/n;
  for i over pixels:
    floats[i] = (float) (pixels[i]*factor);
  ret new FloatBWImage(w, h, floats);
}

Author comment

Began life as a copy of #1035846

download  show line numbers  debug dex  old transpilations   

Travelled to 2 computer(s): mqqgnosmbjvj, wnsclhtenguj

No comments. add comment

-
Snippet ID: #1035864
Snippet name: preciseAverageOfBinaryImages (backup)
Eternal ID of this version: #1035864/1
Text MD5: 4409d1b7c6b3f75331825d12c79921f3
Author: stefan
Category: javax
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2022-08-04 20:01:09
Source code size: 650 bytes / 25 lines
Pitched / IR pitched: No / No
Views / Downloads: 141 / 144
Referenced in: