1 | meta-for IBWIntegralImage in IBWIntegralImage, BWIntegralImage { |
2 | |
3 | // clip is in output coordinates |
4 | static BufferedImage scaledGrayImageFromBWIntegralImage_clip(IBWIntegralImage img, double scalingFactor, Rect clip) { |
5 | int w = clip.w, h = clip.h; |
6 | int w1 = img.getWidth(), h1 = img.getHeight(); |
7 | byte[] pixels = new[w*h]; |
8 | int i = 0; |
9 | int xx2 = clip.x2(), yy2 = clip.y2(); |
10 | for (int y = clip.y; y < yy2; y++) |
11 | for (int x = clip.x; x < xx2; x++) { |
12 | // TODO: optimize |
13 | double x1 = x/scalingFactor, x2 = (x+1)/scalingFactor; |
14 | double y1 = y/scalingFactor, y2 = (y+1)/scalingFactor; |
15 | int pixel = iround(img.getPixelAverage(x1, y1, x2, y2)); |
16 | pixels[i++] = clampToUByte(pixel); |
17 | } |
18 | ret newGrayBufferedImage(w, h, pixels); |
19 | } |
20 | |
21 | } |
Began life as a copy of #1033520
download show line numbers debug dex old transpilations
Travelled to 3 computer(s): bhatertpkbcr, mowyntqkapby, mqqgnosmbjvj
No comments. add comment
Snippet ID: | #1033673 |
Snippet name: | scaledGrayImageFromBWIntegralImage_clip (unoptimized backup) |
Eternal ID of this version: | #1033673/1 |
Text MD5: | 7c870ce42ec40d4be8f711322b6d13de |
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:17:02 |
Source code size: | 813 bytes / 21 lines |
Pitched / IR pitched: | No / No |
Views / Downloads: | 121 / 138 |
Referenced in: | [show references] |