Libraryless. Click here for Pure Java version (7350L/43K).
1 | static BufferedImage scaledBufferedImageFromIntegralImage(int w, IntegralImage img) {
|
2 | ret scaledBufferedImageFromIntegralImage(img, w); |
3 | } |
4 | |
5 | static BufferedImage scaledBufferedImageFromIntegralImage(IntegralImage img, int w) {
|
6 | ret scaledBufferedImageFromIntegralImage(img, w, rowsForColsWithAspectRatio(w, img.w, img.h)); |
7 | } |
8 | |
9 | static BufferedImage scaledBufferedImageFromIntegralImage(int w, int h, IntegralImage img) {
|
10 | ret scaledBufferedImageFromIntegralImage(img, w, h); |
11 | } |
12 | |
13 | static BufferedImage scaledBufferedImageFromIntegralImage(IntegralImage img, int w, int h) {
|
14 | int w1 = img.w, h1 = img.h; |
15 | int[] pixels = new[w*h]; |
16 | int i = 0; |
17 | for y to h: |
18 | for x to w: {
|
19 | int x1 = x*w1/w, x2 = max(x1+1, (x+1)*w1/w); |
20 | int y1 = y*h1/h, y2 = max(y1+1, (y+1)*h1/h); |
21 | int area = (x2-x1)*(y2-y1); |
22 | int r = integralImage_sumRect(img, x1, y1, x2, y2, 0)/area; |
23 | int g = integralImage_sumRect(img, x1, y1, x2, y2, 1)/area; |
24 | int b = integralImage_sumRect(img, x1, y1, x2, y2, 2)/area; |
25 | pixels[i++] = 0xFF000000 | (r << 16) | (g << 8) | b; |
26 | } |
27 | ret intArrayToBufferedImage(pixels, w, h); |
28 | } |
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: | 539 / 690 |
| Version history: | 7 change(s) |
| Referenced in: | [show references] |