#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 403 of file baselinedetect.cpp.
404 : block_(
block), debug_level_(debug_level), non_text_block_(non_text),
405 good_skew_angle_(
false), skew_angle_(0.0),
407 TO_ROW_IT row_it(block_->
get_rows());
408 for (row_it.mark_cycle_pt(); !row_it.cycled_list(); row_it.forward()) {
int blob_x_order(const void *item1, const void *item2)
◆ block()
TO_BLOCK* tesseract::BaselineBlock::block |
( |
| ) |
const |
|
inline |
◆ DrawFinalRows()
void tesseract::BaselineBlock::DrawFinalRows |
( |
const ICOORD & |
page_tr | ) |
|
Definition at line 572 of file baselinedetect.cpp.
573 #ifndef GRAPHICS_DISABLED 574 if (non_text_block_)
return;
575 double gradient = tan(skew_angle_);
576 FCOORD rotation(1.0f, 0.0f);
580 TO_ROW_IT row_it = block_->
get_rows();
581 for (row_it.mark_cycle_pt(); !row_it.cycled_list(); row_it.forward()) {
591 if (block_->
blobs.length() > 0)
592 tprintf(
"%d blobs discarded as noise\n", block_->
blobs.length());
void draw_meanlines(TO_BLOCK *block, float gradient, inT32 left, ScrollView::Color colour, FCOORD rotation)
ScrollView * create_to_win(ICOORD page_tr)
void plot_blob_list(ScrollView *win, BLOBNBOX_LIST *list, ScrollView::Color body_colour, ScrollView::Color child_colour)
void plot_parallel_row(TO_ROW *row, float gradient, inT32 left, ScrollView::Color colour, FCOORD rotation)
void bounding_box(ICOORD &bottom_left, ICOORD &top_right) const
get box
◆ DrawPixSpline()
void tesseract::BaselineBlock::DrawPixSpline |
( |
Pix * |
pix_in | ) |
|
Definition at line 597 of file baselinedetect.cpp.
598 if (non_text_block_)
return;
599 TO_ROW_IT row_it = block_->
get_rows();
600 for (row_it.mark_cycle_pt(); !row_it.cycled_list(); row_it.forward()) {
601 row_it.data()->baseline.plot(pix_in);
◆ FitBaselinesAndFindSkew()
bool tesseract::BaselineBlock::FitBaselinesAndFindSkew |
( |
bool |
use_box_bottoms | ) |
|
Definition at line 429 of file baselinedetect.cpp.
430 if (non_text_block_)
return false;
432 for (
int r = 0; r < rows_.size(); ++r) {
433 BaselineRow* row = rows_[r];
434 if (row->FitBaseline(use_box_bottoms)) {
435 double angle = row->BaselineAngle();
438 if (debug_level_ > 1)
442 if (!angles.
empty()) {
444 good_skew_angle_ =
true;
447 good_skew_angle_ =
false;
449 if (debug_level_ > 0) {
450 tprintf(
"Initial block skew angle = %g, good = %d\n",
451 skew_angle_, good_skew_angle_);
453 return good_skew_angle_;
T MedianOfCircularValues(T modulus, GenericVector< T > *v)
◆ FitBaselineSplines()
void tesseract::BaselineBlock::FitBaselineSplines |
( |
bool |
enable_splines, |
|
|
bool |
show_final_rows, |
|
|
Textord * |
textord |
|
) |
| |
Definition at line 543 of file baselinedetect.cpp.
546 double gradient = tan(skew_angle_);
547 FCOORD rotation(1.0f, 0.0f);
549 if (enable_splines) {
550 textord->make_spline_rows(block_, gradient, show_final_rows);
554 TO_ROW_IT row_it = block_->
get_rows();
555 for (row_it.mark_cycle_pt(); !row_it.cycled_list(); row_it.forward()) {
556 TO_ROW* row = row_it.data();
558 double coeffs[3] = { 0.0, row->
line_m(), row->
line_c() };
564 textord->compute_block_xheight(block_, gradient);
void set_xheight(inT32 height)
set char size
EXTERN bool textord_restore_underlines
FCOORD classify_rotation() const
void restore_underlined_blobs(TO_BLOCK *block)
void bounding_box(ICOORD &bottom_left, ICOORD &top_right) const
get box
◆ ParallelizeBaselines()
void tesseract::BaselineBlock::ParallelizeBaselines |
( |
double |
default_block_skew | ) |
|
Definition at line 458 of file baselinedetect.cpp.
459 if (non_text_block_)
return;
460 if (!good_skew_angle_) skew_angle_ = default_block_skew;
461 if (debug_level_ > 0)
462 tprintf(
"Adjusting block to skew angle %g\n", skew_angle_);
464 for (
int r = 0; r < rows_.size(); ++r) {
465 BaselineRow* row = rows_[r];
466 row->AdjustBaselineToParallel(debug_level_,
direction);
467 if (debug_level_ > 1)
470 if (rows_.size() < 3 || !ComputeLineSpacing())
477 line_spacing_, line_offset_);
478 for (
int r = 1; r < rows_.size(); ++r) {
480 line_spacing_, line_offset_);
481 if (error < best_error) {
487 double offset = line_offset_;
488 for (
int r = best_row + 1; r < rows_.size(); ++r) {
489 offset = rows_[r]->AdjustBaselineToGrid(debug_level_,
direction,
490 line_spacing_, offset);
492 offset = line_offset_;
493 for (
int r = best_row - 1; r >= 0; --r) {
494 offset = rows_[r]->AdjustBaselineToGrid(debug_level_,
direction,
495 line_spacing_, offset);
static double SpacingModelError(double perp_disp, double line_spacing, double line_offset)
int direction(EDGEPT *point)
◆ PrepareForSplineFitting()
void tesseract::BaselineBlock::PrepareForSplineFitting |
( |
ICOORD |
page_tr, |
|
|
bool |
remove_noise |
|
) |
| |
Definition at line 527 of file baselinedetect.cpp.
528 if (non_text_block_)
return;
532 FCOORD rotation(1.0f, 0.0f);
533 double gradient = tan(skew_angle_);
void separate_underlines(TO_BLOCK *block, float gradient, FCOORD rotation, BOOL8 testing_on)
void vigorous_noise_removal(TO_BLOCK *block)
void pre_associate_blobs(ICOORD page_tr, TO_BLOCK *block, FCOORD rotation, BOOL8 testing_on)
◆ SetupBlockParameters()
void tesseract::BaselineBlock::SetupBlockParameters |
( |
| ) |
const |
Definition at line 500 of file baselinedetect.cpp.
501 if (line_spacing_ > 0.0) {
504 if (min_spacing < block_->line_size)
511 TO_ROW_IT row_it(block_->
get_rows());
512 for (
int r = 0; r < rows_.size(); ++r, row_it.forward()) {
513 BaselineRow* row = rows_[r];
514 TO_ROW* to_row = row_it.data();
515 row->SetupOldLineParameters(to_row);
const double kMaxBlobSizeMultiple
◆ 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 417 of file baselinedetect.cpp.
420 int multiple =
IntCastRounded((perp_disp - line_offset) / line_spacing);
421 double model_y = line_spacing * multiple + line_offset;
422 return fabs(perp_disp - model_y);
int IntCastRounded(double x)
The documentation for this class was generated from the following files: