Tesseract  3.02
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
edgblob.h File Reference
#include "scrollview.h"
#include "params.h"
#include "img.h"
#include "ocrblock.h"
#include "coutln.h"
#include "crakedge.h"
#include "notdll.h"

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)
BOOL8 capture_children (OL_BUCKETS *buckets, C_BLOB_IT *reject_it, C_OUTLINE_IT *blob_it)

Macro Definition Documentation

#define BUCKETSIZE   16

Definition at line 31 of file edgblob.h.


Function Documentation

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

Definition at line 449 of file edgblob.cpp.

{
C_OUTLINE *outline; // master outline
inT32 child_count; // no of children
outline = blob_it->data();
child_count = buckets->outline_complexity(outline,
0);
else
child_count = buckets->count_children(outline,
if (child_count > edges_children_count_limit)
return FALSE;
if (child_count > 0)
buckets->extract_children(outline, blob_it);
return TRUE;
}
void empty_buckets ( BLOCK block,
OL_BUCKETS buckets 
)

Definition at line 403 of file edgblob.cpp.

{
BOOL8 good_blob; // healthy blob
C_OUTLINE_LIST outlines; // outlines in block
// iterator
C_OUTLINE_IT out_it = &outlines;
C_OUTLINE_IT bucket_it = buckets->start_scan();
C_OUTLINE_IT parent_it; // parent outline
C_BLOB *blob; // new blob
C_BLOB_IT good_blobs = block->blob_list();
C_BLOB_IT junk_blobs = block->reject_blobs();
while (!bucket_it.empty()) {
out_it.set_to_list(&outlines);
do {
parent_it = bucket_it; // find outermost
do {
bucket_it.forward();
} while (!bucket_it.at_first() &&
!(*parent_it.data() < *bucket_it.data()));
} while (!bucket_it.at_first());
// move to new list
out_it.add_after_then_move(parent_it.extract());
good_blob = capture_children(buckets, &junk_blobs, &out_it);
blob = new C_BLOB(&outlines);
if (good_blob)
good_blobs.add_after_then_move(blob);
else
junk_blobs.add_after_then_move(blob);
bucket_it.set_to_list(buckets->scan_next());
}
}
void extract_edges ( Pix *  pix,
BLOCK block 
)

Definition at line 335 of file edgblob.cpp.

{ // block to scan
C_OUTLINE_LIST outlines; // outlines in block
C_OUTLINE_IT out_it = &outlines;
// TODO(rays) move the pix all the way down to the bottom.
IMAGE image;
image.FromPix(pix);
block_edges(&image, block, &out_it);
ICOORD bleft; // block box
ICOORD tright;
block->bounding_box(bleft, tright);
// make blobs
outlines_to_blobs(block, bleft, tright, &outlines);
}
void fill_buckets ( C_OUTLINE_LIST *  outlines,
OL_BUCKETS buckets 
)

Definition at line 378 of file edgblob.cpp.

{
TBOX ol_box; // outline box
C_OUTLINE_IT out_it = outlines; // iterator
C_OUTLINE_IT bucket_it; // iterator in bucket
C_OUTLINE *outline; // current outline
for (out_it.mark_cycle_pt(); !out_it.cycled_list(); out_it.forward()) {
outline = out_it.extract(); // take off list
// get box
ol_box = outline->bounding_box();
bucket_it.set_to_list((*buckets) (ol_box.left(), ol_box.bottom()));
bucket_it.add_to_end(outline);
}
}
void outlines_to_blobs ( BLOCK block,
ICOORD  bleft,
ICOORD  tright,
C_OUTLINE_LIST *  outlines 
)

Definition at line 359 of file edgblob.cpp.

{
// make buckets
OL_BUCKETS buckets(bleft, tright);
fill_buckets(outlines, &buckets);
empty_buckets(block, &buckets);
}