tesseract  4.0.0-1-g2a2b
edgblob.h File Reference
#include "scrollview.h"
#include "params.h"
#include "ocrblock.h"
#include "coutln.h"
#include "crakedge.h"
#include <memory>

Go to the source code of this file.

Classes

class  OL_BUCKETS
 

Macros

#define BUCKETSIZE   16
 

Functions

void extract_edges (Pix *pix, BLOCK *block)
 
void outlines_to_blobs (BLOCK *block, ICOORD bleft, ICOORD tright, C_OUTLINE_LIST *outlines)
 
void fill_buckets (C_OUTLINE_LIST *outlines, OL_BUCKETS *buckets)
 
void empty_buckets (BLOCK *block, OL_BUCKETS *buckets)
 
bool capture_children (OL_BUCKETS *buckets, C_BLOB_IT *reject_it, C_OUTLINE_IT *blob_it)
 

Macro Definition Documentation

◆ BUCKETSIZE

#define BUCKETSIZE   16

Definition at line 30 of file edgblob.h.

Function Documentation

◆ capture_children()

bool 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_t 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 }
int32_t count_children(C_OUTLINE *outline, int32_t max_count)
Definition: edgblob.cpp:183
EXTERN int edges_children_count_limit
Definition: edgblob.cpp:50
void extract_children(C_OUTLINE *outline, C_OUTLINE_IT *it)
Definition: edgblob.cpp:299
EXTERN bool edges_use_new_outline_complexity
Definition: edgblob.cpp:38
int32_t outline_complexity(C_OUTLINE *outline, int32_t max_count, int16_t depth)
Definition: edgblob.cpp:114

◆ empty_buckets()

void empty_buckets ( BLOCK block,
OL_BUCKETS buckets 
)

Definition at line 398 of file edgblob.cpp.

401  {
402  bool 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 }
C_BLOB_LIST * reject_blobs()
Definition: ocrblock.h:133
C_BLOB_LIST * blob_list()
get blobs
Definition: ocrblock.h:130
bool capture_children(OL_BUCKETS *buckets, C_BLOB_IT *reject_it, C_OUTLINE_IT *blob_it)
Definition: edgblob.cpp:440
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:191
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->pdblk), &out_it);
340  ICOORD bleft; // block box
341  ICOORD tright;
342  block->pdblk.bounding_box(bleft, tright);
343  // make blobs
344  outlines_to_blobs(block, bleft, tright, &outlines);
345 }
void outlines_to_blobs(BLOCK *block, ICOORD bleft, ICOORD tright, C_OUTLINE_LIST *outlines)
Definition: edgblob.cpp:354
integer coordinate
Definition: points.h:32
void bounding_box(ICOORD &bottom_left, ICOORD &top_right) const
get box
Definition: pdblock.h:60
PDBLK pdblk
Definition: ocrblock.h:192
void block_edges(Pix *t_pix, PDBLK *block, C_OUTLINE_IT *outline_it)
Definition: scanedg.cpp:37

◆ 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 }
Definition: rect.h:34
int16_t left() const
Definition: rect.h:72
const TBOX & bounding_box() const
Definition: coutln.h:113
int16_t bottom() const
Definition: rect.h:65

◆ 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 fill_buckets(C_OUTLINE_LIST *outlines, OL_BUCKETS *buckets)
Definition: edgblob.cpp:373
void empty_buckets(BLOCK *block, OL_BUCKETS *buckets)
Definition: edgblob.cpp:398