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

17
LINES

< > BotCompany Repo | #1027256 // dominant332colorsWithPercentage

JavaX fragment (include) [tags: use-pretranspiled]

Libraryless. Click here for Pure Java version (5388L/35K).

// returns pairs (col332 [0-255], percentage of image)
static LPair<Int, Double> dominant332colorsWithPercentage(RGBImage img) {
  int[] array = histogram332_array(img);
  new MultiSet<Int> ms;
  int total = 0;
  for i over array: {
    int x = array[i];
    ms.add(i, x); 
    total += x;
  }
  double total2 = total /= 100;
  ret map(ms.highestFirst(), col -> pair(col, doubleRatio(ms.get(col), total2)));
}

static LPair<Int, Double> dominant332colorsWithPercentage(BufferedImage img) {
  ret dominant332colorsWithPercentage(RGBImage(img));
}

Author comment

Began life as a copy of #1024902

download  show line numbers  debug dex  old transpilations   

Travelled to 7 computer(s): bhatertpkbcr, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tvejysmllsmz, vouqrxazstgt, xrpafgyirdlv

No comments. add comment

Snippet ID: #1027256
Snippet name: dominant332colorsWithPercentage
Eternal ID of this version: #1027256/3
Text MD5: 260d65e42a44927cc51b47a4e8196ead
Transpilation MD5: 4ed799ac441ae008707f425ec7169a10
Author: stefan
Category: javax / image analysis
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2020-02-26 20:53:46
Source code size: 561 bytes / 17 lines
Pitched / IR pitched: No / No
Views / Downloads: 157 / 231
Version history: 2 change(s)
Referenced in: [show references]