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

21
LINES

< > BotCompany Repo | #1033520 // scaledGrayImageFromBWIntegralImage_clip

JavaX fragment (include) [tags: use-pretranspiled]

Libraryless. Click here for Pure Java version (11454L/67K).

meta-for IBWIntegralImage in IBWIntegralImage, BWIntegralImage {

  // clip is in output coordinates
  static BufferedImage scaledGrayImageFromBWIntegralImage_clip(IBWIntegralImage img, double scalingFactor, Rect clip) {
    int w = clip.w, h = clip.h;
    int w1 = img.getWidth(), h1 = img.getHeight();
    byte[] pixels = new[w*h];
    int i = 0;
    int xx2 = clip.x2(), yy2 = clip.y2();
    for (int y = clip.y; y < yy2; y++)
      for (int x = clip.x; x < xx2; x++) {
        // TODO: optimize
        double x1 = x/scalingFactor, x2 = (x+1)/scalingFactor;
        double y1 = y/scalingFactor, y2 = (y+1)/scalingFactor;
        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 4 computer(s): bhatertpkbcr, ekrmjmnbrukm, mowyntqkapby, mqqgnosmbjvj

No comments. add comment

Snippet ID: #1033520
Snippet name: scaledGrayImageFromBWIntegralImage_clip
Eternal ID of this version: #1033520/9
Text MD5: 7c870ce42ec40d4be8f711322b6d13de
Transpilation MD5: a8b3ab639fce4f6139ca2c9127dd61d9
Author: stefan
Category: javax / imaging
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2021-11-03 18:49:14
Source code size: 813 bytes / 21 lines
Pitched / IR pitched: No / No
Views / Downloads: 170 / 247
Version history: 8 change(s)
Referenced in: #1006654 - Standard functions list 2 (LIVE, continuation of #761)
#1033673 - scaledGrayImageFromBWIntegralImage_clip (unoptimized backup)