Libraryless. Click here for Pure Java version (6758L/40K).
1 | static RGBImage scaleDownUsingIntegralImage(IIntegralImage img, int w) {
|
2 | ret scaleDownUsingIntegralImage(img, w, heightForWidth(img.getWidth(), img.getHeight(), w)); |
3 | } |
4 | |
5 | static RGBImage scaleDownUsingIntegralImage(IIntegralImage img, int w, int h) {
|
6 | int w1 = img.getWidth(), h1 = img.getHeight(); |
7 | RGBImage out = new(w, h); |
8 | for y to h: |
9 | for x to w: {
|
10 | int x1 = x*w1/w, x2 = max(x1+1, (x+1)*w1/w); |
11 | int y1 = y*h1/h, y2 = max(y1+1, (y+1)*h1/h); |
12 | int area = (x2-x1)*(y2-y1); |
13 | int r = roundedRatio(img.rectSum(x1, y1, x2, y2, 0), area); |
14 | int g = roundedRatio(img.rectSum(x1, y1, x2, y2, 1), area); |
15 | int b = roundedRatio(img.rectSum(x1, y1, x2, y2, 2), area); |
16 | out.setPixel(x, y, r, g, b); |
17 | } |
18 | ret out; |
19 | } |
download show line numbers debug dex old transpilations
Travelled to 12 computer(s): bhatertpkbcr, cbybwowwnfue, cfunsshuasjs, gwrvuhgaqvyk, irmadwmeruwu, ishqpsrjomds, lpdgvwnxivlt, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tvejysmllsmz, vouqrxazstgt
No comments. add comment
| Snippet ID: | #1019590 |
| Snippet name: | scaleDownUsingIntegralImage (can also scale up) |
| Eternal ID of this version: | #1019590/9 |
| Text MD5: | dce7738bd59245a4f2de5e4e0f98e746 |
| Transpilation MD5: | ab41dd2af9b7fcfa9d44c5be3cfb74ba |
| Author: | stefan |
| Category: | javax / imaging |
| Type: | JavaX fragment (include) |
| Public (visible to everyone): | Yes |
| Archived (hidden from active list): | No |
| Created/modified: | 2021-08-05 23:47:07 |
| Source code size: | 765 bytes / 19 lines |
| Pitched / IR pitched: | No / No |
| Views / Downloads: | 686 / 860 |
| Version history: | 8 change(s) |
| Referenced in: | [show references] |