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

15
LINES

< > BotCompany Repo | #1006251 // bwImageTo2Bit

JavaX fragment (include)

static BWImage bwImageTo2Bit(BWImage img, float threshold) {
  int w = img.w(), h = img.h();
  BWImage img2 = new BWImage(w, h);
  for y to h: for x to w:
    img2.setPixel(x, y, img.getPixel(x, y) >= threshold ? 1f : 0f);
  ret img2;
}

static BWImage bwImageTo2Bit(BWImage img) {
  ret bwImageTo2Bit(0.5f, img);
}

static BWImage bwImageTo2Bit(float threshold, BWImage img) {
  ret bwImageTo2Bit(img, threshold);
}

download  show line numbers  debug dex  old transpilations   

Travelled to 14 computer(s): aoiabmzegqzx, bhatertpkbcr, cbybwowwnfue, cfunsshuasjs, gwrvuhgaqvyk, ishqpsrjomds, lpdgvwnxivlt, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, sawdedvomwva, tslmcundralx, tvejysmllsmz, vouqrxazstgt

No comments. add comment

Snippet ID: #1006251
Snippet name: bwImageTo2Bit
Eternal ID of this version: #1006251/3
Text MD5: 2b6757e6dc9f5111b1383f10156d9da9
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 15:10:19
Source code size: 430 bytes / 15 lines
Pitched / IR pitched: No / No
Views / Downloads: 583 / 627
Version history: 2 change(s)
Referenced in: [show references]