Libraryless. Click here for Pure Java version (5277L/34K).
1 | static BufferedImage scaledBufferedImageFromIntegralImage_direct(int w, IntegralImage img) {
|
2 | ret scaledBufferedImageFromIntegralImage_direct(img, w); |
3 | } |
4 | |
5 | static BufferedImage scaledBufferedImageFromIntegralImage_direct(IntegralImage img, int w) {
|
6 | ret scaledBufferedImageFromIntegralImage_direct(img, w, rowsForColsWithAspectRatio(w, img.w, img.h)); |
7 | } |
8 | |
9 | static BufferedImage scaledBufferedImageFromIntegralImage_direct(IntegralImage img, int w, int h) {
|
10 | int w1 = img.w, h1 = img.h; |
11 | BufferedImage out = newBufferedImage(w, h); |
12 | for y to h: |
13 | for x to w: {
|
14 | int x1 = x*w1/w, x2 = max(x1+1, (x+1)*w1/w); |
15 | int y1 = y*h1/h, y2 = max(y1+1, (y+1)*h1/h); |
16 | int area = (x2-x1)*(y2-y1); |
17 | int r = integralImage_sumRect(img, x1, y1, x2, y2, 0)/area; |
18 | int g = integralImage_sumRect(img, x1, y1, x2, y2, 1)/area; |
19 | int b = integralImage_sumRect(img, x1, y1, x2, y2, 2)/area; |
20 | out.setRGB(x, y, (r << 16) | (g << 8) | b); |
21 | } |
22 | ret out; |
23 | } |
Began life as a copy of #1025282
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: | #1025285 |
| Snippet name: | scaledBufferedImageFromIntegralImage_direct (slower than the non-direct version) |
| Eternal ID of this version: | #1025285/4 |
| Text MD5: | 594c19b275fd30f5865ce77a833885b4 |
| Transpilation MD5: | 374338a7d66ddd115a7d391b58778e31 |
| Author: | stefan |
| Category: | javax / imaging |
| Type: | JavaX fragment (include) |
| Public (visible to everyone): | Yes |
| Archived (hidden from active list): | No |
| Created/modified: | 2019-09-18 15:05:04 |
| Source code size: | 987 bytes / 23 lines |
| Pitched / IR pitched: | No / No |
| Views / Downloads: | 469 / 598 |
| Version history: | 3 change(s) |
| Referenced in: | [show references] |