Libraryless. Click here for Pure Java version (7350L/43K).
static BufferedImage scaledBufferedImageFromIntegralImage(int w, IntegralImage img) { ret scaledBufferedImageFromIntegralImage(img, w); } static BufferedImage scaledBufferedImageFromIntegralImage(IntegralImage img, int w) { ret scaledBufferedImageFromIntegralImage(img, w, rowsForColsWithAspectRatio(w, img.w, img.h)); } static BufferedImage scaledBufferedImageFromIntegralImage(int w, int h, IntegralImage img) { ret scaledBufferedImageFromIntegralImage(img, w, h); } static BufferedImage scaledBufferedImageFromIntegralImage(IntegralImage img, int w, int h) { int w1 = img.w, h1 = img.h; int[] pixels = new[w*h]; int i = 0; for y to h: for x to w: { int x1 = x*w1/w, x2 = max(x1+1, (x+1)*w1/w); int y1 = y*h1/h, y2 = max(y1+1, (y+1)*h1/h); int area = (x2-x1)*(y2-y1); int r = integralImage_sumRect(img, x1, y1, x2, y2, 0)/area; int g = integralImage_sumRect(img, x1, y1, x2, y2, 1)/area; int b = integralImage_sumRect(img, x1, y1, x2, y2, 2)/area; pixels[i++] = 0xFF000000 | (r << 16) | (g << 8) | b; } ret intArrayToBufferedImage(pixels, w, h); }
Began life as a copy of #1019590
download show line numbers debug dex old transpilations
Travelled to 6 computer(s): bhatertpkbcr, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tvejysmllsmz, vouqrxazstgt
No comments. add comment
Snippet ID: | #1025282 |
Snippet name: | scaledBufferedImageFromIntegralImage |
Eternal ID of this version: | #1025282/8 |
Text MD5: | 2b289cdc0c5dd8086101d5e5822f0a65 |
Transpilation MD5: | f6e9009ca495066bb008d3e0fd27585d |
Author: | stefan |
Category: | javax / imaging |
Type: | JavaX fragment (include) |
Public (visible to everyone): | Yes |
Archived (hidden from active list): | No |
Created/modified: | 2021-08-07 17:11:10 |
Source code size: | 1145 bytes / 28 lines |
Pitched / IR pitched: | No / No |
Views / Downloads: | 299 / 400 |
Version history: | 7 change(s) |
Referenced in: | [show references] |