|
tesseract
3.03
|
#include <blobs.h>
Public Member Functions | |
| TWERD () | |
| TWERD (const TWERD &src) | |
| ~TWERD () | |
| TWERD & | operator= (const TWERD &src) |
| void | BLNormalize (const BLOCK *block, const ROW *row, Pix *pix, bool inverse, float x_height, bool numeric_mode, tesseract::OcrEngineMode hint, const TBOX *norm_box, DENORM *word_denorm) |
| void | CopyFrom (const TWERD &src) |
| void | Clear () |
| void | ComputeBoundingBoxes () |
| int | NumBlobs () const |
| TBOX | bounding_box () const |
| void | MergeBlobs (int start, int end) |
| void | plot (ScrollView *window) |
Static Public Member Functions | |
| static TWERD * | PolygonalCopy (bool allow_detailed_fx, WERD *src) |
Public Attributes | |
| GenericVector< TBLOB * > | blobs |
| bool | latin_script |
| TWERD::TWERD | ( | ) | [inline] |
Definition at line 303 of file blobs.h.
: latin_script(false) {}
| TWERD::TWERD | ( | const TWERD & | src | ) | [inline] |
| TWERD::~TWERD | ( | ) | [inline] |
| void TWERD::BLNormalize | ( | const BLOCK * | block, |
| const ROW * | row, | ||
| Pix * | pix, | ||
| bool | inverse, | ||
| float | x_height, | ||
| bool | numeric_mode, | ||
| tesseract::OcrEngineMode | hint, | ||
| const TBOX * | norm_box, | ||
| DENORM * | word_denorm | ||
| ) |
Definition at line 741 of file blobs.cpp.
{
TBOX word_box = bounding_box();
if (norm_box != NULL) word_box = *norm_box;
float word_middle = (word_box.left() + word_box.right()) / 2.0f;
float input_y_offset = 0.0f;
float final_y_offset = static_cast<float>(kBlnBaselineOffset);
float scale = kBlnXHeight / x_height;
if (hint == tesseract::OEM_CUBE_ONLY || row == NULL) {
word_middle = word_box.left();
input_y_offset = word_box.bottom();
final_y_offset = 0.0f;
if (hint == tesseract::OEM_CUBE_ONLY)
scale = 1.0f;
} else {
input_y_offset = row->base_line(word_middle);
}
for (int b = 0; b < blobs.size(); ++b) {
TBLOB* blob = blobs[b];
TBOX blob_box = blob->bounding_box();
float mid_x = (blob_box.left() + blob_box.right()) / 2.0f;
float baseline = input_y_offset;
float blob_scale = scale;
if (numeric_mode) {
baseline = blob_box.bottom();
blob_scale = ClipToRange(kBlnXHeight * 4.0f / (3 * blob_box.height()),
scale, scale * 1.5f);
} else if (row != NULL && hint != tesseract::OEM_CUBE_ONLY) {
baseline = row->base_line(mid_x);
}
// The image will be 8-bit grey if the input was grey or color. Note that in
// a grey image 0 is black and 255 is white. If the input was binary, then
// the pix will be binary and 0 is white, with 1 being black.
// To tell the difference pixGetDepth() will return 8 or 1.
// The inverse flag will be true iff the word has been determined to be
// white on black, and is independent of whether the pix is 8 bit or 1 bit.
blob->Normalize(block, NULL, NULL, word_middle, baseline, blob_scale,
blob_scale, 0.0f, final_y_offset, inverse, pix);
}
if (word_denorm != NULL) {
word_denorm->SetupNormalization(block, NULL, NULL, word_middle,
input_y_offset, scale, scale,
0.0f, final_y_offset);
word_denorm->set_inverse(inverse);
word_denorm->set_pix(pix);
}
}
| TBOX TWERD::bounding_box | ( | ) | const |
| void TWERD::Clear | ( | ) |
| void TWERD::ComputeBoundingBoxes | ( | ) |
| void TWERD::CopyFrom | ( | const TWERD & | src | ) |
| void TWERD::MergeBlobs | ( | int | start, |
| int | end | ||
| ) |
Definition at line 826 of file blobs.cpp.
{
if (start >= blobs.size() - 1) return; // Nothing to do.
TESSLINE* outline = blobs[start]->outlines;
for (int i = start + 1; i < end && i < blobs.size(); ++i) {
TBLOB* next_blob = blobs[i];
// Take the outlines from the next blob.
if (outline == NULL) {
blobs[start]->outlines = next_blob->outlines;
outline = blobs[start]->outlines;
} else {
while (outline->next != NULL)
outline = outline->next;
outline->next = next_blob->outlines;
next_blob->outlines = NULL;
}
// Delete the next blob and move on.
delete next_blob;
blobs[i] = NULL;
}
// Remove dead blobs from the vector.
for (int i = start + 1; i < end && start + 1 < blobs.size(); ++i) {
blobs.remove(start + 1);
}
}
| int TWERD::NumBlobs | ( | ) | const [inline] |
| void TWERD::plot | ( | ScrollView * | window | ) |
Definition at line 852 of file blobs.cpp.
{
ScrollView::Color color = WERD::NextColor(ScrollView::BLACK);
for (int b = 0; b < blobs.size(); ++b) {
blobs[b]->plot(window, color, ScrollView::BROWN);
color = WERD::NextColor(color);
}
}
| TWERD * TWERD::PolygonalCopy | ( | bool | allow_detailed_fx, |
| WERD * | src | ||
| ) | [static] |
Definition at line 727 of file blobs.cpp.
{
TWERD* tessword = new TWERD;
tessword->latin_script = src->flag(W_SCRIPT_IS_LATIN);
C_BLOB_IT b_it(src->cblob_list());
for (b_it.mark_cycle_pt(); !b_it.cycled_list(); b_it.forward()) {
C_BLOB* blob = b_it.data();
TBLOB* tblob = TBLOB::PolygonalCopy(allow_detailed_fx, blob);
tessword->blobs.push_back(tblob);
}
return tessword;
}
| bool TWERD::latin_script |