1 | static double pixelSetRectangleness_factor = 5; |
2 | |
3 | static double pixelSetRectangleness(PixelSet set) {
|
4 | ret (pixelSetRectangleness_dimension(pixelSetBoundsByLine(set)) |
5 | + pixelSetRectangleness_dimension(pixelSetBoundsByColumn(set)))/2; |
6 | } |
7 | |
8 | static double pixelSetRectangleness_dimension(L<IntRange> l) {
|
9 | int[] a = intRangeStarts(l), b = intRangeEnds(l); |
10 | double avgL = doubleAverage(a), avgR = doubleAverage(b); |
11 | double width = avgR-avgL; |
12 | double dev = standardDeviation(b)+standardDeviation(a); |
13 | print("width=" + width + ", dev=" + dev);
|
14 | ret max(0, 1-dev*pixelSetRectangleness_factor/width); |
15 | } |
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: | 849 / 821 |
| Version history: | 6 change(s) |
| Referenced in: | [show references] |