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

13
LINES

< > BotCompany Repo | #1024725 // img_squaredDistanceFromColor_withGain (gain before squaring)

JavaX fragment (include)

static BWImage img_squaredDistanceFromColor_withGain(RGBImage img, RGB color, double gain) {
  int w = img.getWidth(), h = img.getHeight();
  int col = color.getInt();
  BWImage bw = new(w, h);
  for y to h:
    for x to w:
      bw.setPixel(x, y, sqr(rgbDiff(img.getInt(x, y), col)*(float) gain));
  ret bw;
}

static BWImage img_squaredDistanceFromColor_withGain(BufferedImage img, RGB color, double gain) {
  ret img_squaredDistanceFromColor_withGain(RGBImage(img), color, gain);
}

Author comment

Began life as a copy of #1024559

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: #1024725
Snippet name: img_squaredDistanceFromColor_withGain (gain before squaring)
Eternal ID of this version: #1024725/1
Text MD5: 784e10d90e6d109bc695cf2788e4d9ca
Author: stefan
Category: javax / imaging
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2019-08-24 14:32:33
Source code size: 496 bytes / 13 lines
Pitched / IR pitched: No / No
Views / Downloads: 141 / 173
Referenced in: [show references]