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

25
LINES

< > BotCompany Repo | #1018616 // horizontalAutoSplit_inverse [uses column average brightness, for white on black text/audio]

JavaX fragment (include)

static float horizontalAutoSplit_inverse_threshold = 0.1f;

static L<Rect> horizontalAutoSplit_inverse(BWImage img) {
  ret horizontalAutoSplit_inverse(img, horizontalAutoSplit_inverse_threshold);
}

static L<Rect> horizontalAutoSplit_inverse(BWImage img, float threshold) {
  int w = img.getWidth(), h = img.getHeight();
  float[] f = bwImageColumnBrightnesses(img);
  
  new L<Rect> l;
  int j = -1;
  for (int i = 0; i < l(f); i++)
    if (f[i] >= threshold) { // start / continue streak
      if (j < 0) j = i; 
    } else {
      if (j >= 0) { // end streak
        l.add(new Rect(j, 0, i-j, h));
        j = -1;
      }
    }
  if (j >= 0)
    l.add(new Rect(j, 0, w-j, h));
  ret l;
}

Author comment

Began life as a copy of #1005709

download  show line numbers  debug dex  old transpilations   

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

No comments. add comment

Snippet ID: #1018616
Snippet name: horizontalAutoSplit_inverse [uses column average brightness, for white on black text/audio]
Eternal ID of this version: #1018616/1
Text MD5: 44c1a2e4567665448f65ad7765b775bb
Author: stefan
Category: javax / ocr
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2018-10-08 00:54:15
Source code size: 715 bytes / 25 lines
Pitched / IR pitched: No / No
Views / Downloads: 351 / 379
Referenced in: [show references]