1 | static BufferedImage scaledGrayImageFromBWIntegralImage(int w, BWIntegralImage img) { |
2 | ret scaledGrayImageFromBWIntegralImage(img, w); |
3 | } |
4 | |
5 | static BufferedImage scaledGrayImageFromBWIntegralImage(BWIntegralImage img, int w, int h default heightForWidth(img.w, img.h, w)) { |
6 | int w1 = img.w, h1 = img.h; |
7 | byte[] pixels = new[w*h]; |
8 | int i = 0; |
9 | for y to h: |
10 | for x to w: { |
11 | // TODO: optimize |
12 | int x1 = x*w1/w, x2 = max(x1+1, (x+1)*w1/w); |
13 | int y1 = y*h1/h, y2 = max(y1+1, (y+1)*h1/h); |
14 | int pixel = iround(img.getPixelAverage(x1, y1, x2, y2)); |
15 | pixels[i++] = clampToUByte(pixel; |
16 | } |
17 | ret newGrayBufferedImage(w, h, pixels); |
18 | } |
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: | 117 / 139 |
Referenced in: | [show references] |