Not logged in.  Login/Logout/Register | List snippets | | Create snippet | Upload image | Upload data

12
LINES

< > BotCompany Repo | #1007153 // rgbAverageColor

JavaX fragment (include)

static RGB rgbAverageColor(RGBImage img) {
  int w = img.w(), h = img.h();
  double r = 0, g = 0, b = 0;
  for y to h: for x to w: {
    RGB rgb = img.getPixel(x, y);
    r += rgb.r;
    g += rgb.g;
    b += rgb.b;
  }
  int n = w*h;
  ret new RGB(r/n, g/n, b/n);
}

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: 373 / 385
Referenced in: [show references]