本文整理汇总了C++中TBLOB::Normalize方法的典型用法代码示例。如果您正苦于以下问题:C++ TBLOB::Normalize方法的具体用法?C++ TBLOB::Normalize怎么用?C++ TBLOB::Normalize使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TBLOB
的用法示例。
在下文中一共展示了TBLOB::Normalize方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: BLNormalize
// Baseline normalizes the blobs in-place, recording the normalization in the
// DENORMs in the blobs.
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) {
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);
}
}
示例2: Normalize
// Normalize in-place using the DENORM.
void TWERD::Normalize(const DENORM& denorm) {
for (TBLOB* blob = blobs; blob != NULL; blob = blob->next) {
blob->Normalize(denorm);
}
}