tesseract  5.0.0-alpha-619-ge9db
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 29 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 435 of file edgblob.cpp.

439  {
440  C_OUTLINE *outline; // master outline
441  int32_t child_count; // no of children
442 
443  outline = blob_it->data();
444  if (edges_use_new_outline_complexity)
445  child_count = buckets->outline_complexity(outline,
446  edges_children_count_limit,
447  0);
448  else
449  child_count = buckets->count_children(outline,
450  edges_children_count_limit);
451  if (child_count > edges_children_count_limit)
452  return false;
453 
454  if (child_count > 0)
455  buckets->extract_children(outline, blob_it);
456  return true;
457 }

◆ empty_buckets()

void empty_buckets ( BLOCK block,
OL_BUCKETS buckets 
)

Definition at line 393 of file edgblob.cpp.

396  {
397  bool good_blob; // healthy blob
398  C_OUTLINE_LIST outlines; // outlines in block
399  // iterator
400  C_OUTLINE_IT out_it = &outlines;
401  C_OUTLINE_IT bucket_it = buckets->start_scan();
402  C_OUTLINE_IT parent_it; // parent outline
403  C_BLOB_IT good_blobs = block->blob_list();
404  C_BLOB_IT junk_blobs = block->reject_blobs();
405 
406  while (!bucket_it.empty()) {
407  out_it.set_to_list(&outlines);
408  do {
409  parent_it = bucket_it; // find outermost
410  do {
411  bucket_it.forward();
412  } while (!bucket_it.at_first() &&
413  !(*parent_it.data() < *bucket_it.data()));
414  } while (!bucket_it.at_first());
415 
416  // move to new list
417  out_it.add_after_then_move(parent_it.extract());
418  good_blob = capture_children(buckets, &junk_blobs, &out_it);
419  C_BLOB::ConstructBlobsFromOutlines(good_blob, &outlines, &good_blobs,
420  &junk_blobs);
421 
422  bucket_it.set_to_list(buckets->scan_next());
423  }
424 }

◆ extract_edges()

void extract_edges ( Pix *  pix,
BLOCK block 
)

Definition at line 329 of file edgblob.cpp.

330  { // block to scan
331  C_OUTLINE_LIST outlines; // outlines in block
332  C_OUTLINE_IT out_it = &outlines;
333 
334  block_edges(pix, &(block->pdblk), &out_it);
335  ICOORD bleft; // block box
336  ICOORD tright;
337  block->pdblk.bounding_box(bleft, tright);
338  // make blobs
339  outlines_to_blobs(block, bleft, tright, &outlines);
340 }

◆ fill_buckets()

void fill_buckets ( C_OUTLINE_LIST *  outlines,
OL_BUCKETS buckets 
)

Definition at line 368 of file edgblob.cpp.

371  {
372  TBOX ol_box; // outline box
373  C_OUTLINE_IT out_it = outlines; // iterator
374  C_OUTLINE_IT bucket_it; // iterator in bucket
375  C_OUTLINE *outline; // current outline
376 
377  for (out_it.mark_cycle_pt(); !out_it.cycled_list(); out_it.forward()) {
378  outline = out_it.extract(); // take off list
379  // get box
380  ol_box = outline->bounding_box();
381  bucket_it.set_to_list((*buckets) (ol_box.left(), ol_box.bottom()));
382  bucket_it.add_to_end(outline);
383  }
384 }

◆ outlines_to_blobs()

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

Definition at line 349 of file edgblob.cpp.

353  {
354  // make buckets
355  OL_BUCKETS buckets(bleft, tright);
356 
357  fill_buckets(outlines, &buckets);
358  empty_buckets(block, &buckets);
359 }
PDBLK::bounding_box
void bounding_box(ICOORD &bottom_left, ICOORD &top_right) const
get box
Definition: pdblock.h:58
ICOORD
integer coordinate
Definition: points.h:30
C_BLOB::ConstructBlobsFromOutlines
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:184
OL_BUCKETS
Definition: edgblob.h:31
OL_BUCKETS::outline_complexity
int32_t outline_complexity(C_OUTLINE *outline, int32_t max_count, int16_t depth)
Definition: edgblob.cpp:109
capture_children
bool capture_children(OL_BUCKETS *buckets, C_BLOB_IT *reject_it, C_OUTLINE_IT *blob_it)
Definition: edgblob.cpp:435
C_OUTLINE
Definition: coutln.h:71
BLOCK::pdblk
PDBLK pdblk
Page Description Block.
Definition: ocrblock.h:189
TBOX::bottom
int16_t bottom() const
Definition: rect.h:64
OL_BUCKETS::count_children
int32_t count_children(C_OUTLINE *outline, int32_t max_count)
Definition: edgblob.cpp:178
fill_buckets
void fill_buckets(C_OUTLINE_LIST *outlines, OL_BUCKETS *buckets)
Definition: edgblob.cpp:368
block_edges
void block_edges(Pix *t_pix, PDBLK *block, C_OUTLINE_IT *outline_it)
Definition: scanedg.cpp:35
OL_BUCKETS::start_scan
C_OUTLINE_LIST * start_scan()
Definition: edgblob.h:44
outlines_to_blobs
void outlines_to_blobs(BLOCK *block, ICOORD bleft, ICOORD tright, C_OUTLINE_LIST *outlines)
Definition: edgblob.cpp:349
OL_BUCKETS::scan_next
C_OUTLINE_LIST * scan_next()
Definition: edgblob.h:50
TBOX::left
int16_t left() const
Definition: rect.h:71
empty_buckets
void empty_buckets(BLOCK *block, OL_BUCKETS *buckets)
Definition: edgblob.cpp:393
BLOCK::blob_list
C_BLOB_LIST * blob_list()
get blobs
Definition: ocrblock.h:127
C_OUTLINE::bounding_box
const TBOX & bounding_box() const
Definition: coutln.h:112
OL_BUCKETS::extract_children
void extract_children(C_OUTLINE *outline, C_OUTLINE_IT *it)
Definition: edgblob.cpp:294
BLOCK::reject_blobs
C_BLOB_LIST * reject_blobs()
Definition: ocrblock.h:130
TBOX
Definition: rect.h:33