#include <baselinedetect.h>
|
static double | SpacingModelError (double perp_disp, double line_spacing, double line_offset) |
|
Definition at line 129 of file baselinedetect.h.
◆ BaselineBlock()
tesseract::BaselineBlock::BaselineBlock |
( |
int |
debug_level, |
|
|
bool |
non_text, |
|
|
TO_BLOCK * |
block |
|
) |
| |
Definition at line 408 of file baselinedetect.cpp.
409 : block_(
block), debug_level_(debug_level), non_text_block_(non_text),
410 good_skew_angle_(
false), skew_angle_(0.0),
412 TO_ROW_IT row_it(block_->
get_rows());
413 for (row_it.mark_cycle_pt(); !row_it.cycled_list(); row_it.forward()) {
◆ block()
TO_BLOCK* tesseract::BaselineBlock::block |
( |
| ) |
const |
|
inline |
◆ DrawFinalRows()
void tesseract::BaselineBlock::DrawFinalRows |
( |
const ICOORD & |
page_tr | ) |
|
Definition at line 577 of file baselinedetect.cpp.
578 #ifndef GRAPHICS_DISABLED
579 if (non_text_block_)
return;
580 double gradient = tan(skew_angle_);
581 FCOORD rotation(1.0f, 0.0f);
585 TO_ROW_IT row_it = block_->
get_rows();
586 for (row_it.mark_cycle_pt(); !row_it.cycled_list(); row_it.forward()) {
588 colour = static_cast<ScrollView::Color>(colour + 1);
596 if (block_->
blobs.length() > 0)
597 tprintf(
"%d blobs discarded as noise\n", block_->
blobs.length());
◆ DrawPixSpline()
void tesseract::BaselineBlock::DrawPixSpline |
( |
Pix * |
pix_in | ) |
|
Definition at line 602 of file baselinedetect.cpp.
603 if (non_text_block_)
return;
604 TO_ROW_IT row_it = block_->
get_rows();
605 for (row_it.mark_cycle_pt(); !row_it.cycled_list(); row_it.forward()) {
606 row_it.data()->baseline.plot(pix_in);
◆ FitBaselinesAndFindSkew()
bool tesseract::BaselineBlock::FitBaselinesAndFindSkew |
( |
bool |
use_box_bottoms | ) |
|
Definition at line 434 of file baselinedetect.cpp.
435 if (non_text_block_)
return false;
437 for (
int r = 0; r < rows_.size(); ++r) {
438 BaselineRow* row = rows_[r];
439 if (row->FitBaseline(use_box_bottoms)) {
440 double angle = row->BaselineAngle();
443 if (debug_level_ > 1)
447 if (!angles.
empty()) {
449 good_skew_angle_ =
true;
452 good_skew_angle_ =
false;
454 if (debug_level_ > 0) {
455 tprintf(
"Initial block skew angle = %g, good = %d\n",
456 skew_angle_, good_skew_angle_);
458 return good_skew_angle_;
◆ FitBaselineSplines()
void tesseract::BaselineBlock::FitBaselineSplines |
( |
bool |
enable_splines, |
|
|
bool |
show_final_rows, |
|
|
Textord * |
textord |
|
) |
| |
Definition at line 548 of file baselinedetect.cpp.
551 double gradient = tan(skew_angle_);
552 FCOORD rotation(1.0f, 0.0f);
554 if (enable_splines) {
555 textord->make_spline_rows(block_, gradient, show_final_rows);
559 TO_ROW_IT row_it = block_->
get_rows();
560 for (row_it.mark_cycle_pt(); !row_it.cycled_list(); row_it.forward()) {
561 TO_ROW* row = row_it.data();
562 int32_t xstarts[2] = { block_box.
left(), block_box.
right() };
563 double coeffs[3] = { 0.0, row->
line_m(), row->
line_c() };
569 textord->compute_block_xheight(block_, gradient);
◆ ParallelizeBaselines()
void tesseract::BaselineBlock::ParallelizeBaselines |
( |
double |
default_block_skew | ) |
|
Definition at line 463 of file baselinedetect.cpp.
464 if (non_text_block_)
return;
465 if (!good_skew_angle_) skew_angle_ = default_block_skew;
466 if (debug_level_ > 0)
467 tprintf(
"Adjusting block to skew angle %g\n", skew_angle_);
468 FCOORD direction(cos(skew_angle_), sin(skew_angle_));
469 for (
int r = 0; r < rows_.size(); ++r) {
470 BaselineRow* row = rows_[r];
471 row->AdjustBaselineToParallel(debug_level_, direction);
472 if (debug_level_ > 1)
475 if (rows_.size() < 3 || !ComputeLineSpacing())
482 line_spacing_, line_offset_);
483 for (
int r = 1; r < rows_.size(); ++r) {
485 line_spacing_, line_offset_);
486 if (error < best_error) {
492 double offset = line_offset_;
493 for (
int r = best_row + 1; r < rows_.size(); ++r) {
494 offset = rows_[r]->AdjustBaselineToGrid(debug_level_, direction,
495 line_spacing_, offset);
497 offset = line_offset_;
498 for (
int r = best_row - 1; r >= 0; --r) {
499 offset = rows_[r]->AdjustBaselineToGrid(debug_level_, direction,
500 line_spacing_, offset);
◆ PrepareForSplineFitting()
void tesseract::BaselineBlock::PrepareForSplineFitting |
( |
ICOORD |
page_tr, |
|
|
bool |
remove_noise |
|
) |
| |
Definition at line 532 of file baselinedetect.cpp.
533 if (non_text_block_)
return;
537 FCOORD rotation(1.0f, 0.0f);
538 double gradient = tan(skew_angle_);
◆ SetupBlockParameters()
void tesseract::BaselineBlock::SetupBlockParameters |
( |
| ) |
const |
Definition at line 505 of file baselinedetect.cpp.
506 if (line_spacing_ > 0.0) {
508 float min_spacing = std::min(block_->
line_spacing, static_cast<float>(line_spacing_));
509 if (min_spacing < block_->line_size)
516 TO_ROW_IT row_it(block_->
get_rows());
517 for (
int r = 0; r < rows_.size(); ++r, row_it.forward()) {
518 BaselineRow* row = rows_[r];
519 TO_ROW* to_row = row_it.data();
520 row->SetupOldLineParameters(to_row);
◆ skew_angle()
double tesseract::BaselineBlock::skew_angle |
( |
| ) |
const |
|
inline |
◆ SpacingModelError()
double tesseract::BaselineBlock::SpacingModelError |
( |
double |
perp_disp, |
|
|
double |
line_spacing, |
|
|
double |
line_offset |
|
) |
| |
|
static |
Definition at line 422 of file baselinedetect.cpp.
425 int multiple =
IntCastRounded((perp_disp - line_offset) / line_spacing);
426 double model_y = line_spacing * multiple + line_offset;
427 return fabs(perp_disp - model_y);
The documentation for this class was generated from the following files: