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

19
LINES

< > BotCompany Repo | #1004644 // unsubtitle

JavaX fragment (include)

static Pair<BWImage, S> unsubtitle(BWImage img) {
  int h = img.getHeight(), y1 = h-12;
  if (y1 < 0) null;
  int w = img.getWidth();
  int x1 = w, x2 = 0;
  for (int x = 0; x < w; x++)
    if (img.getPixel(x, y1) < 0.5) {
      x1 = min(x1, x);
      x2 = max(x2, x+1);
      if (img.getPixel(x, h-1) >= 0.5) null;
    } else
      if (img.getPixel(x, h-1) < 0.5) null;
      
  if (x1 > x2) null;
  BWImage sub = img.clip(x1-1, y1, x2-x1+2, h-y1);
  //showBWImage(sub);
  S text = imageToUtf(sub);
  ret pair(img.clip(0, 0, w, y1), text);
}

download  show line numbers  debug dex  old transpilations   

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

No comments. add comment

Snippet ID: #1004644
Snippet name: unsubtitle
Eternal ID of this version: #1004644/1
Text MD5: b6e5f3f8b97d58cf4ac07ebc2f452b7a
Author: stefan
Category: javax / images
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2016-08-24 19:50:53
Source code size: 560 bytes / 19 lines
Pitched / IR pitched: No / No
Views / Downloads: 556 / 569
Referenced in: #1006654 - Standard functions list 2 (LIVE, continuation of #761)