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

24
LINES

< > BotCompany Repo | #1030509 // bwii_detectSingleLine

JavaX fragment (include) [tags: use-pretranspiled]

Libraryless. Compilation Failed (6414L/39K).

1  
// background must be white
2  
static Pair<Pt> bwii_detectSingleLine(IBWIntegralImage ii) {
3  
  int whiteValue = 255;
4  
  int imgW = ii.getWidth(), imgH = ii.getHeight();
5  
  IIntIntPred predX = (x1, x2) -> ii.getPixelAverage(x1, 0, x2, imgH) != whiteValue;
6  
  IIntIntPred predY = (y1, y2) -> ii.getPixelAverage(0, y1, imgW, y2) != whiteValue;
7  
  
8  
  // find bounding box
9  
  
10  
  Pair<Pt> endpoints = pair(
11  
    pt(indexOfRangePredicate_IIntIntPred(imgW, predX),
12  
       indexOfRangePredicate_IIntIntPred(imgH, predY)),
13  
    pt(lastIndexOfRangePredicate_IIntIntPred(imgW, predX),
14  
       lastIndexOfRangePredicate_IIntIntPred(imgH, predY)));
15  
       
16  
  // find out which diagonal it is
17  
  
18  
  if (ii.getPixel(endpoints.a) > ii.getPixel(endpoints.b.x, endpoints.a.y)) {
19  
    int temp = endpoints.b.x;
20  
    endpoints.b.x = endpoints.a.x;
21  
    endpoints.a.x = temp;
22  
  }
23  
  ret endpoints;
24  
}

download  show line numbers  debug dex  old transpilations   

Travelled to 4 computer(s): bhatertpkbcr, mqqgnosmbjvj, pyentgdyhuwx, vouqrxazstgt

No comments. add comment

Snippet ID: #1030509
Snippet name: bwii_detectSingleLine
Eternal ID of this version: #1030509/16
Text MD5: aed63258952572953ea8774b819c8b6f
Transpilation MD5: 5e7410f9519d12f5ae849c813989c0ac
Author: stefan
Category: javax / ocr
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2021-01-07 01:50:54
Source code size: 883 bytes / 24 lines
Pitched / IR pitched: No / No
Views / Downloads: 266 / 384
Version history: 15 change(s)
Referenced in: [show references]