Libraryless. Click here for Pure Java version (4667L/26K).
1 | static BufferedImage grayImageFromIBWImage(IBWImage img) { |
2 | int w = img.getWidth(), h = img.getHeight(); |
3 | byte[] pixels = new[w*h]; |
4 | int i = 0; |
5 | for y to h: |
6 | for x to w: { |
7 | int pixel = iround(img.getFloatPixel(x, y)*255); // tODO: is it round or floor? |
8 | ifdef grayImageFromIBWIntegralImage_debug |
9 | if (x == 0 && y == 0) print(+pixel); |
10 | endifdef |
11 | pixels[i++] = clampToUByte(pixel; |
12 | } |
13 | ret newGrayBufferedImage(w, h, pixels); |
14 | } |
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: | 177 / 245 |
Referenced in: | [show references] |