tesseract 4.1.1
Loading...
Searching...
No Matches
edgblob.cpp File Reference
#include "scanedg.h"
#include "edgloop.h"
#include "edgblob.h"

Go to the source code of this file.

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.

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

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}
int32_t outline_complexity(C_OUTLINE *outline, int32_t max_count, int16_t depth)
Definition: edgblob.cpp:109
void extract_children(C_OUTLINE *outline, C_OUTLINE_IT *it)
Definition: edgblob.cpp:294
int32_t count_children(C_OUTLINE *outline, int32_t max_count)
Definition: edgblob.cpp:178

◆ 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}
bool capture_children(OL_BUCKETS *buckets, C_BLOB_IT *reject_it, C_OUTLINE_IT *blob_it)
Definition: edgblob.cpp:435
C_BLOB_LIST * blob_list()
get blobs
Definition: ocrblock.h:128
C_BLOB_LIST * reject_blobs()
Definition: ocrblock.h:131
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:189
C_OUTLINE_LIST * start_scan()
Definition: edgblob.h:45
C_OUTLINE_LIST * scan_next()
Definition: edgblob.h:51

◆ 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}
void outlines_to_blobs(BLOCK *block, ICOORD bleft, ICOORD tright, C_OUTLINE_LIST *outlines)
Definition: edgblob.cpp:349
void block_edges(Pix *t_pix, PDBLK *block, C_OUTLINE_IT *outline_it)
Definition: scanedg.cpp:37
PDBLK pdblk
Page Description Block.
Definition: ocrblock.h:190
void bounding_box(ICOORD &bottom_left, ICOORD &top_right) const
get box
Definition: pdblock.h:59
integer coordinate
Definition: points.h:32

◆ 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}
const TBOX & bounding_box() const
Definition: coutln.h:113
Definition: rect.h:34
int16_t left() const
Definition: rect.h:72
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 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}
void empty_buckets(BLOCK *block, OL_BUCKETS *buckets)
Definition: edgblob.cpp:393
void fill_buckets(C_OUTLINE_LIST *outlines, OL_BUCKETS *buckets)
Definition: edgblob.cpp:368