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

28
LINES

< > BotCompany Repo | #1018617 // audioSplit1 [uses column average brightness, for frequency images]

JavaX fragment (include)

sbool audioSplit1_debug = true;
static float audioSplit1_threshold = 0.025f;

static L<IntRange> audioSplit1(BWImage img) {
  ret audioSplit1(img, audioSplit1_threshold);
}

static L<IntRange> audioSplit1(BWImage img, float threshold) {
  int w = img.getWidth();
  float[] f = bwImageColumnBrightnesses(img);
  
  new L<IntRange> 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(intRange(j, i));
        j = -1;
      }
    }
  if (j >= 0)
    l.add(intRange(j, w));
  if (audioSplit1_debug)
    print("audioSplit1: " + w + " => " + sfu(l));
  ret l;
}

Author comment

Began life as a copy of #1018616

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: #1018617
Snippet name: audioSplit1 [uses column average brightness, for frequency images]
Eternal ID of this version: #1018617/6
Text MD5: fe26a20853784de2e7d6560eefeef9ce
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 01:07:21
Source code size: 722 bytes / 28 lines
Pitched / IR pitched: No / No
Views / Downloads: 379 / 411
Version history: 5 change(s)
Referenced in: [show references]