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

15
LINES

< > BotCompany Repo | #1010190 // pixelSetRectangleness - looks at all borders

JavaX fragment (include)

static double pixelSetRectangleness_factor = 5;

static double pixelSetRectangleness(PixelSet set) {
  ret (pixelSetRectangleness_dimension(pixelSetBoundsByLine(set))
    + pixelSetRectangleness_dimension(pixelSetBoundsByColumn(set)))/2;
}

static double pixelSetRectangleness_dimension(L<IntRange> l) {
  int[] a = intRangeStarts(l), b = intRangeEnds(l);
  double avgL = doubleAverage(a), avgR = doubleAverage(b);
  double width = avgR-avgL;
  double dev = standardDeviation(b)+standardDeviation(a);
  print("width=" + width + ", dev=" + dev);
  ret max(0, 1-dev*pixelSetRectangleness_factor/width);
}

download  show line numbers  debug dex  old transpilations   

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

No comments. add comment

Snippet ID: #1010190
Snippet name: pixelSetRectangleness - looks at all borders
Eternal ID of this version: #1010190/7
Text MD5: faab22ba20bf9f24819049cd98e67096
Author: stefan
Category: javax / ocr
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2017-09-06 00:51:19
Source code size: 616 bytes / 15 lines
Pitched / IR pitched: No / No
Views / Downloads: 604 / 575
Version history: 6 change(s)
Referenced in: [show references]