tesseract  4.00.00dev
edgblob.cpp File Reference
#include "scanedg.h"
#include "drawedg.h"
#include "edgloop.h"
#include "edgblob.h"

Go to the source code of this file.

Macros

#define EXTERN
 

Functions

extract_edges

Run the edge detector over the block and return a list of blobs.

void extract_edges (Pix *pix, BLOCK *block)
 
outlines_to_blobs

Gather together outlines into blobs using the usual bucket sort.

void outlines_to_blobs (BLOCK *block, ICOORD bleft, ICOORD tright, C_OUTLINE_LIST *outlines)
 
fill_buckets

Run the edge detector over the block and return a list of blobs.

void fill_buckets (C_OUTLINE_LIST *outlines, OL_BUCKETS *buckets)
 
empty_buckets

Run the edge detector over the block and return a list of blobs.

void empty_buckets (BLOCK *block, OL_BUCKETS *buckets)
 
capture_children

Find all neighbouring outlines that are children of this outline and either move them to the output list or declare this outline illegal and return FALSE.

BOOL8 capture_children (OL_BUCKETS *buckets, C_BLOB_IT *reject_it, C_OUTLINE_IT *blob_it)
 

Variables

EXTERN bool edges_use_new_outline_complexity = FALSE
 
EXTERN int edges_max_children_per_outline = 10
 
EXTERN int edges_max_children_layers = 5
 
EXTERN bool edges_debug = FALSE
 
EXTERN int edges_children_per_grandchild = 10
 
EXTERN int edges_children_count_limit = 45
 
EXTERN bool edges_children_fix = FALSE
 
EXTERN int edges_min_nonhole = 12
 
EXTERN int edges_patharea_ratio = 40
 
EXTERN double edges_childarea = 0.5
 
EXTERN double edges_boxarea = 0.875
 

Macro Definition Documentation

◆ EXTERN

#define EXTERN

Definition at line 30 of file edgblob.cpp.

Function Documentation

◆ capture_children()

BOOL8 capture_children ( OL_BUCKETS buckets,
C_BLOB_IT *  reject_it,
C_OUTLINE_IT *  blob_it 
)

Definition at line 440 of file edgblob.cpp.

444  {
445  C_OUTLINE *outline; // master outline
446  inT32 child_count; // no of children
447 
448  outline = blob_it->data();
450  child_count = buckets->outline_complexity(outline,
452  0);
453  else
454  child_count = buckets->count_children(outline,
456  if (child_count > edges_children_count_limit)
457  return FALSE;
458 
459  if (child_count > 0)
460  buckets->extract_children(outline, blob_it);
461  return TRUE;
462 }
#define TRUE
Definition: capi.h:45
int32_t inT32
Definition: host.h:38
EXTERN int edges_children_count_limit
Definition: edgblob.cpp:50
EXTERN bool edges_use_new_outline_complexity
Definition: edgblob.cpp:38
#define FALSE
Definition: capi.h:46
inT32 outline_complexity(C_OUTLINE *outline, inT32 max_count, inT16 depth)
Definition: edgblob.cpp:114
void extract_children(C_OUTLINE *outline, C_OUTLINE_IT *it)
Definition: edgblob.cpp:299
inT32 count_children(C_OUTLINE *outline, inT32 max_count)
Definition: edgblob.cpp:183

◆ empty_buckets()

void empty_buckets ( BLOCK block,
OL_BUCKETS buckets 
)

Definition at line 398 of file edgblob.cpp.

401  {
402  BOOL8 good_blob; // healthy blob
403  C_OUTLINE_LIST outlines; // outlines in block
404  // iterator
405  C_OUTLINE_IT out_it = &outlines;
406  C_OUTLINE_IT bucket_it = buckets->start_scan();
407  C_OUTLINE_IT parent_it; // parent outline
408  C_BLOB_IT good_blobs = block->blob_list();
409  C_BLOB_IT junk_blobs = block->reject_blobs();
410 
411  while (!bucket_it.empty()) {
412  out_it.set_to_list(&outlines);
413  do {
414  parent_it = bucket_it; // find outermost
415  do {
416  bucket_it.forward();
417  } while (!bucket_it.at_first() &&
418  !(*parent_it.data() < *bucket_it.data()));
419  } while (!bucket_it.at_first());
420 
421  // move to new list
422  out_it.add_after_then_move(parent_it.extract());
423  good_blob = capture_children(buckets, &junk_blobs, &out_it);
424  C_BLOB::ConstructBlobsFromOutlines(good_blob, &outlines, &good_blobs,
425  &junk_blobs);
426 
427  bucket_it.set_to_list(buckets->scan_next());
428  }
429 }
BOOL8 capture_children(OL_BUCKETS *buckets, C_BLOB_IT *reject_it, C_OUTLINE_IT *blob_it)
Definition: edgblob.cpp:440
C_BLOB_LIST * reject_blobs()
Definition: ocrblock.h:135
C_OUTLINE_LIST * scan_next()
Definition: edgblob.h:51
static void ConstructBlobsFromOutlines(bool good_blob, C_OUTLINE_LIST *outline_list, C_BLOB_IT *good_blobs_it, C_BLOB_IT *bad_blobs_it)
Definition: stepblob.cpp:186
unsigned char BOOL8
Definition: host.h:44
C_BLOB_LIST * blob_list()
get blobs
Definition: ocrblock.h:132
C_OUTLINE_LIST * start_scan()
Definition: edgblob.h:45

◆ extract_edges()

void extract_edges ( Pix *  pix,
BLOCK block 
)

Definition at line 334 of file edgblob.cpp.

335  { // block to scan
336  C_OUTLINE_LIST outlines; // outlines in block
337  C_OUTLINE_IT out_it = &outlines;
338 
339  block_edges(pix, block, &out_it);
340  ICOORD bleft; // block box
341  ICOORD tright;
342  block->bounding_box(bleft, tright);
343  // make blobs
344  outlines_to_blobs(block, bleft, tright, &outlines);
345 }
void bounding_box(ICOORD &bottom_left, ICOORD &top_right) const
get box
Definition: pdblock.h:59
void block_edges(Pix *t_pix, PDBLK *block, C_OUTLINE_IT *outline_it)
Definition: scanedg.cpp:38
integer coordinate
Definition: points.h:30
void outlines_to_blobs(BLOCK *block, ICOORD bleft, ICOORD tright, C_OUTLINE_LIST *outlines)
Definition: edgblob.cpp:354

◆ fill_buckets()

void fill_buckets ( C_OUTLINE_LIST *  outlines,
OL_BUCKETS buckets 
)

Definition at line 373 of file edgblob.cpp.

376  {
377  TBOX ol_box; // outline box
378  C_OUTLINE_IT out_it = outlines; // iterator
379  C_OUTLINE_IT bucket_it; // iterator in bucket
380  C_OUTLINE *outline; // current outline
381 
382  for (out_it.mark_cycle_pt(); !out_it.cycled_list(); out_it.forward()) {
383  outline = out_it.extract(); // take off list
384  // get box
385  ol_box = outline->bounding_box();
386  bucket_it.set_to_list((*buckets) (ol_box.left(), ol_box.bottom()));
387  bucket_it.add_to_end(outline);
388  }
389 }
inT16 left() const
Definition: rect.h:68
const TBOX & bounding_box() const
Definition: coutln.h:111
Definition: rect.h:30
inT16 bottom() const
Definition: rect.h:61

◆ outlines_to_blobs()

void outlines_to_blobs ( BLOCK block,
ICOORD  bleft,
ICOORD  tright,
C_OUTLINE_LIST *  outlines 
)

Definition at line 354 of file edgblob.cpp.

358  {
359  // make buckets
360  OL_BUCKETS buckets(bleft, tright);
361 
362  fill_buckets(outlines, &buckets);
363  empty_buckets(block, &buckets);
364 }
void empty_buckets(BLOCK *block, OL_BUCKETS *buckets)
Definition: edgblob.cpp:398
void fill_buckets(C_OUTLINE_LIST *outlines, OL_BUCKETS *buckets)
Definition: edgblob.cpp:373

Variable Documentation

◆ edges_boxarea

EXTERN double edges_boxarea = 0.875

"Min area fraction of grandchild for box"

Definition at line 60 of file edgblob.cpp.

◆ edges_childarea

EXTERN double edges_childarea = 0.5

"Min area fraction of child outline"

Definition at line 58 of file edgblob.cpp.

◆ edges_children_count_limit

EXTERN int edges_children_count_limit = 45

"Max holes allowed in blob"

Definition at line 50 of file edgblob.cpp.

◆ edges_children_fix

EXTERN bool edges_children_fix = FALSE

"Remove boxy parents of char-like children"

Definition at line 52 of file edgblob.cpp.

◆ edges_children_per_grandchild

EXTERN int edges_children_per_grandchild = 10

"Importance ratio for chucking outlines"

Definition at line 48 of file edgblob.cpp.

◆ edges_debug

EXTERN bool edges_debug = FALSE

"turn on debugging for this module"

Definition at line 44 of file edgblob.cpp.

◆ edges_max_children_layers

EXTERN int edges_max_children_layers = 5

"Max layers of nested children inside a character outline"

Definition at line 42 of file edgblob.cpp.

◆ edges_max_children_per_outline

EXTERN int edges_max_children_per_outline = 10

"Max number of children inside a character outline"

Definition at line 40 of file edgblob.cpp.

◆ edges_min_nonhole

EXTERN int edges_min_nonhole = 12

"Min pixels for potential char in box"

Definition at line 54 of file edgblob.cpp.

◆ edges_patharea_ratio

EXTERN int edges_patharea_ratio = 40

"Max lensq/area for acceptable child outline"

Definition at line 56 of file edgblob.cpp.

◆ edges_use_new_outline_complexity

EXTERN bool edges_use_new_outline_complexity = FALSE

"Use the new outline complexity module"

Definition at line 38 of file edgblob.cpp.