1 | static RGB rgbAverageColor(RGBImage img) { |
2 | int w = img.w(), h = img.h(); |
3 | double r = 0, g = 0, b = 0; |
4 | for y to h: for x to w: { |
5 | RGB rgb = img.getPixel(x, y); |
6 | r += rgb.r; |
7 | g += rgb.g; |
8 | b += rgb.b; |
9 | } |
10 | int n = w*h; |
11 | ret new RGB(r/n, g/n, b/n); |
12 | } |
download show line numbers debug dex old transpilations
Travelled to 13 computer(s): aoiabmzegqzx, bhatertpkbcr, cbybwowwnfue, cfunsshuasjs, gwrvuhgaqvyk, ishqpsrjomds, lpdgvwnxivlt, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tslmcundralx, tvejysmllsmz, vouqrxazstgt
No comments. add comment
Snippet ID: | #1007153 |
Snippet name: | rgbAverageColor |
Eternal ID of this version: | #1007153/1 |
Text MD5: | 5aa91ea6cf4a4c9a2f1dc31b887b7e04 |
Author: | stefan |
Category: | javax / imaging |
Type: | JavaX fragment (include) |
Public (visible to everyone): | Yes |
Archived (hidden from active list): | No |
Created/modified: | 2017-03-08 00:56:30 |
Source code size: | 276 bytes / 12 lines |
Pitched / IR pitched: | No / No |
Views / Downloads: | 442 / 450 |
Referenced in: | [show references] |