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

14
LINES

< > BotCompany Repo | #1033574 // grayImageFromIBWImage

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

Libraryless. Click here for Pure Java version (4667L/26K).

static BufferedImage grayImageFromIBWImage(IBWImage img) {
  int w = img.getWidth(), h = img.getHeight();
  byte[] pixels = new[w*h];
  int i = 0;
  for y to h:
    for x to w: {
      int pixel = iround(img.getFloatPixel(x, y)*255); // tODO: is it round or floor?
      ifdef grayImageFromIBWIntegralImage_debug
        if (x == 0 && y == 0) print(+pixel);
      endifdef
      pixels[i++] = clampToUByte(pixel;
    }
  ret newGrayBufferedImage(w, h, pixels);
}

Author comment

Began life as a copy of #1033567

download  show line numbers  debug dex  old transpilations   

Travelled to 4 computer(s): bhatertpkbcr, ekrmjmnbrukm, mowyntqkapby, mqqgnosmbjvj

No comments. add comment

Snippet ID: #1033574
Snippet name: grayImageFromIBWImage
Eternal ID of this version: #1033574/1
Text MD5: 95c3fd4b3eb4ec787ca32005d3bdd655
Transpilation MD5: 360cf4feb4cb1fcef2a568e7e8c7f5bb
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 20:16:13
Source code size: 475 bytes / 14 lines
Pitched / IR pitched: No / No
Views / Downloads: 176 / 243
Referenced in: #1006654 - Standard functions list 2 (LIVE, continuation of #761)