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

57
LINES

< > BotCompany Repo | #1032154 // RecursiveImageSplitter - probabilistic (of course) [dev.]

JavaX fragment (include)

1  
srecord noeq RecursiveImageSplitter(
2  
  IProbabilisticScheduler scheduler,
3  
  URecognizer recognizer) {
4  
  
5  
  replace Cell with URecognizer.Cell.
6  
  
7  
  Node root;
8  
  int minPixelSize = 64; // don't dive below this (for the splitting)
9  
  
10  
  // actual class for leaves, base class for split nodes
11  
  class Node > Pair<Node> { // funky type
12  
    Cell cell;
13  
    int color;
14  
    
15  
    // known error (distance to image). will go up as image is
16  
    // scanned in more detail.
17  
    double error;
18  
    
19  
    *() {}
20  
    *(Cell *cell) {
21  
      color = cell.intColor();
22  
    }
23  
    
24  
    // availability - how important are we? (our percentage of total area)
25  
    double availability() { ret recognizer.relativeArea(position); }
26  
    
27  
    double splitPossibility() {
28  
      ret zeroOrOne(diameter(position) < minPixelSize);
29  
    }
30  
    
31  
    Rect position() { ret cell.rectInImage(); }
32  
    
33  
    void scheduleSplits {
34  
      var p = availability() * splitProbability();
35  
      scheduler.at(p, r splitHorizontally);
36  
      scheduler.at(p, r splitVertically);
37  
    }
38  
    
39  
    void splitHorizontally {
40  
      
41  
    }
42  
    
43  
    void splitVertically { /* TODO */ }
44  
  }
45  
46  
  class Split > Node {
47  
    int splitDimension;
48  
    int splitPoint;
49  
  }
50  
51  
  run {
52  
    // make single color root from top cell.
53  
    // let the node schedule its possible splits.
54  
    root = Node(recognizer.cell());
55  
    root.scheduleSplits();
56  
  }
57  
}

Author comment

Began life as a copy of #1032053

download  show line numbers  debug dex  old transpilations   

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

No comments. add comment

Snippet ID: #1032154
Snippet name: RecursiveImageSplitter - probabilistic (of course) [dev.]
Eternal ID of this version: #1032154/1
Text MD5: bee15f51035f89a69c96fe3539986ad5
Author: stefan
Category: javax / probabilistic computing / images
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2021-08-15 02:56:03
Source code size: 1422 bytes / 57 lines
Pitched / IR pitched: No / No
Views / Downloads: 152 / 172
Referenced in: [show references]