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

25
LINES

< > BotCompany Repo | #1026941 // bwContrastQuadtree_minOfArea [approach doesn't work]

JavaX fragment (include)

1  
static int bwContrastQuadtree_minOfArea(BWImage min, Rect rect) {
2  
  ret bwContrastQuadtree_minOfArea(min, rect, imageRect(min));
3  
}
4  
5  
static int bwContrastQuadtree_minOfArea(BWImage min, Rect rect, Rect block) {
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 min.getInt(block.x, block.y);
12  
  
13  
  // complex case: process subregions
14  
  int w = block.w, hx = (w+1)/2;
15  
  int h = block.h, hy = (h+1)/2;
16  
  ret intMin(
17  
    // top left area
18  
    bwContrastQuadtree_minOfArea(min, r2, Rect(block.x, block.y, hx, hy)),
19  
    // tall slice on the right
20  
    bwContrastQuadtree_minOfArea(min, r2, Rect(block.x+hx, block.y, w-hx, h)),
21  
    // wide slice on the bottom
22  
    bwContrastQuadtree_minOfArea(min, r2, Rect(block.x, block.y+hy, w, h-hy)),
23  
    // bottom right area
24  
    bwContrastQuadtree_minOfArea(min, r2, Rect(block.x+hx, block.y+hy, w-hx, h-hy)));
25  
}

Author comment

Began life as a copy of #1026934

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: #1026941
Snippet name: bwContrastQuadtree_minOfArea [approach doesn't work]
Eternal ID of this version: #1026941/1
Text MD5: 70bb4f5e9686658fd6deeec48605a058
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 03:13:38
Source code size: 1009 bytes / 25 lines
Pitched / IR pitched: No / No
Views / Downloads: 209 / 234
Referenced in: [show references]