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

18
LINES

< > BotCompany Repo | #1033674 // scaledGrayImageFromBWIntegralImage (unoptimized backup)

JavaX fragment (include)

static BufferedImage scaledGrayImageFromBWIntegralImage(int w, BWIntegralImage img) {
  ret scaledGrayImageFromBWIntegralImage(img, w);
}

static BufferedImage scaledGrayImageFromBWIntegralImage(BWIntegralImage img, int w, int h default heightForWidth(img.w, img.h, w)) {
  int w1 = img.w, h1 = img.h;
  byte[] pixels = new[w*h];
  int i = 0;
  for y to h:
    for x to w: {
      // TODO: optimize
      int x1 = x*w1/w, x2 = max(x1+1, (x+1)*w1/w);
      int y1 = y*h1/h, y2 = max(y1+1, (y+1)*h1/h);
      int pixel = iround(img.getPixelAverage(x1, y1, x2, y2));
      pixels[i++] = clampToUByte(pixel;
    }
  ret newGrayBufferedImage(w, h, pixels);
}

Author comment

Began life as a copy of #1033440

download  show line numbers  debug dex  old transpilations   

Travelled to 3 computer(s): bhatertpkbcr, mowyntqkapby, mqqgnosmbjvj

No comments. add comment

Snippet ID: #1033674
Snippet name: scaledGrayImageFromBWIntegralImage (unoptimized backup)
Eternal ID of this version: #1033674/1
Text MD5: 2168ae9695a2530b384b83f0d869a141
Author: stefan
Category: javax / imaging
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2021-12-26 18:33:16
Source code size: 670 bytes / 18 lines
Pitched / IR pitched: No / No
Views / Downloads: 57 / 74
Referenced in: [show references]