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

25
LINES

< > BotCompany Repo | #1026934 // bwContrastQuadtree_minOfArea [OK]

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

Libraryless. Click here for Pure Java version (2400L/15K).

1  
static int bwContrastQuadtree_minOfArea(BWContrastQuadTree qt, int originalSize, Rect rect) {
2  
  ret bwContrastQuadtree_minOfArea(qt, Rect(0, 0, originalSize, originalSize), rect);
3  
}
4  
5  
static int bwContrastQuadtree_minOfArea(BWContrastQuadTree qt, Rect block, Rect rect) {
6  
  Rect r2 = intersectRects(rect, block);
7  
  if (r2.empty()) ret 255; // simple case 1: no intersection
8  
  print(rect + " => " + r2);
9  
  
10  
  // simple case 2: whole block
11  
  if (eq(r2, block)) ret qt.min();
12  
  
13  
  // simple case 3: block is one color
14  
  if (!(qt instanceof BWContrastQuadTree.Composite))
15  
    ret qt.min();
16  
  
17  
  // complex case: process subregions
18  
  BWContrastQuadTree.Composite qt2 = cast qt;
19  
  int w = block.w, r = w/2;
20  
  ret intMin(
21  
    bwContrastQuadtree_minOfArea(qt2.a, Rect(block.x, block.y, r, r), r2),
22  
    bwContrastQuadtree_minOfArea(qt2.b, Rect(block.x+r, block.y, r, r), r2),
23  
    bwContrastQuadtree_minOfArea(qt2.c, Rect(block.x, block.y+r, r, r), r2),
24  
    bwContrastQuadtree_minOfArea(qt2.d, Rect(block.x+r, block.y+r, r, r), r2));
25  
}

Author comment

Began life as a copy of #1019596

download  show line numbers  debug dex  old transpilations   

Travelled to 7 computer(s): bhatertpkbcr, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tvejysmllsmz, vouqrxazstgt, xrpafgyirdlv

No comments. add comment

Snippet ID: #1026934
Snippet name: bwContrastQuadtree_minOfArea [OK]
Eternal ID of this version: #1026934/21
Text MD5: a2d3c4ec97a6e9bb1d2b7b72302d8487
Transpilation MD5: 55bb4ff411dc18b55467f12655c9b689
Author: stefan
Category: javax / ocr
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2020-02-03 13:18:31
Source code size: 1050 bytes / 25 lines
Pitched / IR pitched: No / No
Views / Downloads: 251 / 398
Version history: 20 change(s)
Referenced in: [show references]