tesseract  4.0.0-1-g2a2b
TO_ROW Class Reference

#include <blobbox.h>

Inheritance diagram for TO_ROW:
ELIST2_LINK

Public Member Functions

 TO_ROW ()
 
 TO_ROW (BLOBNBOX *blob, float top, float bottom, float row_size)
 
void print () const
 
float max_y () const
 
float min_y () const
 
float mean_y () const
 
float initial_min_y () const
 
float line_m () const
 
float line_c () const
 
float line_error () const
 
float parallel_c () const
 
float parallel_error () const
 
float believability () const
 
float intercept () const
 
void add_blob (BLOBNBOX *blob, float top, float bottom, float row_size)
 
void insert_blob (BLOBNBOX *blob)
 
BLOBNBOX_LIST * blob_list ()
 
void set_line (float new_m, float new_c, float new_error)
 
void set_parallel_line (float gradient, float new_c, float new_error)
 
void set_limits (float new_min, float new_max)
 
void compute_vertical_projection ()
 
bool rep_chars_marked () const
 
void clear_rep_chars_marked ()
 
int num_repeated_sets () const
 
void set_num_repeated_sets (int num_sets)
 
- Public Member Functions inherited from ELIST2_LINK
 ELIST2_LINK ()
 
 ELIST2_LINK (const ELIST2_LINK &)
 
void operator= (const ELIST2_LINK &)
 

Public Attributes

bool merged
 
bool all_caps
 
bool used_dm_model
 
int16_t projection_left
 
int16_t projection_right
 
PITCH_TYPE pitch_decision
 
float fixed_pitch
 
float fp_space
 
float fp_nonsp
 
float pr_space
 
float pr_nonsp
 
float spacing
 
float xheight
 
int xheight_evidence
 
float ascrise
 
float descdrop
 
float body_size
 
int32_t min_space
 
int32_t max_nonspace
 
int32_t space_threshold
 
float kern_size
 
float space_size
 
WERD_LIST rep_words
 
ICOORDELT_LIST char_cells
 
QSPLINE baseline
 
STATS projection
 

Static Public Attributes

static const int kErrorWeight = 3
 

Detailed Description

Definition at line 556 of file blobbox.h.

Constructor & Destructor Documentation

◆ TO_ROW() [1/2]

TO_ROW::TO_ROW ( )
inline

Definition at line 561 of file blobbox.h.

561  {
562  clear();
563  } //empty

◆ TO_ROW() [2/2]

TO_ROW::TO_ROW ( BLOBNBOX blob,
float  top,
float  bottom,
float  row_size 
)

Definition at line 690 of file blobbox.cpp.

695  {
696  clear();
697  y_min = bottom;
698  y_max = top;
699  initial_y_min = bottom;
700 
701  float diff; //in size
702  BLOBNBOX_IT it = &blobs; //list of blobs
703 
704  it.add_to_end (blob);
705  diff = top - bottom - row_size;
706  if (diff > 0) {
707  y_max -= diff / 2;
708  y_min += diff / 2;
709  }
710  //very small object
711  else if ((top - bottom) * 3 < row_size) {
712  diff = row_size / 3 + bottom - top;
713  y_max += diff / 2;
714  y_min -= diff / 2;
715  }
716 }

Member Function Documentation

◆ add_blob()

void TO_ROW::add_blob ( BLOBNBOX blob,
float  top,
float  bottom,
float  row_size 
)

Definition at line 734 of file blobbox.cpp.

739  {
740  float allowed; //allowed expansion
741  float available; //expansion
742  BLOBNBOX_IT it = &blobs; //list of blobs
743 
744  it.add_to_end (blob);
745  allowed = row_size + y_min - y_max;
746  if (allowed > 0) {
747  available = top > y_max ? top - y_max : 0;
748  if (bottom < y_min)
749  //total available
750  available += y_min - bottom;
751  if (available > 0) {
752  available += available; //do it gradually
753  if (available < allowed)
754  available = allowed;
755  if (bottom < y_min)
756  y_min -= (y_min - bottom) * allowed / available;
757  if (top > y_max)
758  y_max += (top - y_max) * allowed / available;
759  }
760  }
761 }

◆ believability()

float TO_ROW::believability ( ) const
inline

Definition at line 598 of file blobbox.h.

598  { //baseline goodness
599  return credibility;
600  }

◆ blob_list()

BLOBNBOX_LIST* TO_ROW::blob_list ( )
inline

Definition at line 612 of file blobbox.h.

612  { //get list
613  return &blobs;
614  }

◆ clear_rep_chars_marked()

void TO_ROW::clear_rep_chars_marked ( )
inline

Definition at line 647 of file blobbox.h.

647  {
648  num_repeated_sets_ = -1;
649  }

◆ compute_vertical_projection()

void TO_ROW::compute_vertical_projection ( )

Definition at line 797 of file blobbox.cpp.

797  { //project whole row
798  TBOX row_box; //bound of row
799  BLOBNBOX *blob; //current blob
800  TBOX blob_box; //bounding box
801  BLOBNBOX_IT blob_it = blob_list ();
802 
803  if (blob_it.empty ())
804  return;
805  row_box = blob_it.data ()->bounding_box ();
806  for (blob_it.mark_cycle_pt (); !blob_it.cycled_list (); blob_it.forward ())
807  row_box += blob_it.data ()->bounding_box ();
808 
810  row_box.right () + PROJECTION_MARGIN);
811  projection_left = row_box.left () - PROJECTION_MARGIN;
813  for (blob_it.mark_cycle_pt (); !blob_it.cycled_list (); blob_it.forward ()) {
814  blob = blob_it.data();
815  if (blob->cblob() != nullptr)
817  }
818 }
Definition: rect.h:34
int16_t projection_right
Definition: blobbox.h:662
int16_t left() const
Definition: rect.h:72
STATS projection
Definition: blobbox.h:684
bool set_range(int32_t min_bucket_value, int32_t max_bucket_value_plus_1)
Definition: statistc.cpp:63
int16_t projection_left
Definition: blobbox.h:661
int16_t right() const
Definition: rect.h:79
#define PROJECTION_MARGIN
Definition: blobbox.cpp:38
void vertical_cblob_projection(C_BLOB *blob, STATS *stats)
Definition: blobbox.cpp:869
C_BLOB * cblob() const
Definition: blobbox.h:269
BLOBNBOX_LIST * blob_list()
Definition: blobbox.h:612

◆ initial_min_y()

float TO_ROW::initial_min_y ( ) const
inline

Definition at line 580 of file blobbox.h.

580  {
581  return initial_y_min;
582  }

◆ insert_blob()

void TO_ROW::insert_blob ( BLOBNBOX blob)

Definition at line 770 of file blobbox.cpp.

772  {
773  BLOBNBOX_IT it = &blobs; //list of blobs
774 
775  if (it.empty ())
776  it.add_before_then_move (blob);
777  else {
778  it.mark_cycle_pt ();
779  while (!it.cycled_list ()
780  && it.data ()->bounding_box ().left () <=
781  blob->bounding_box ().left ())
782  it.forward ();
783  if (it.cycled_list ())
784  it.add_to_end (blob);
785  else
786  it.add_before_stay_put (blob);
787  }
788 }
int16_t left() const
Definition: rect.h:72
const TBOX & bounding_box() const
Definition: blobbox.h:231

◆ intercept()

float TO_ROW::intercept ( ) const
inline

Definition at line 601 of file blobbox.h.

601  { //real parallel_c
602  return y_origin;
603  }

◆ line_c()

float TO_ROW::line_c ( ) const
inline

Definition at line 586 of file blobbox.h.

586  {
587  return c;
588  }

◆ line_error()

float TO_ROW::line_error ( ) const
inline

Definition at line 589 of file blobbox.h.

589  {
590  return error;
591  }

◆ line_m()

float TO_ROW::line_m ( ) const
inline

Definition at line 583 of file blobbox.h.

583  { //access to line fit
584  return m;
585  }

◆ max_y()

float TO_ROW::max_y ( ) const
inline

Definition at line 571 of file blobbox.h.

571  { //access function
572  return y_max;
573  }

◆ mean_y()

float TO_ROW::mean_y ( ) const
inline

Definition at line 577 of file blobbox.h.

577  {
578  return (y_min + y_max) / 2.0f;
579  }

◆ min_y()

float TO_ROW::min_y ( ) const
inline

Definition at line 574 of file blobbox.h.

574  {
575  return y_min;
576  }

◆ num_repeated_sets()

int TO_ROW::num_repeated_sets ( ) const
inline

Definition at line 650 of file blobbox.h.

650  {
651  return num_repeated_sets_;
652  }

◆ parallel_c()

float TO_ROW::parallel_c ( ) const
inline

Definition at line 592 of file blobbox.h.

592  {
593  return para_c;
594  }

◆ parallel_error()

float TO_ROW::parallel_error ( ) const
inline

Definition at line 595 of file blobbox.h.

595  {
596  return para_error;
597  }

◆ print()

void TO_ROW::print ( ) const

Definition at line 718 of file blobbox.cpp.

718  {
719  tprintf("pitch=%d, fp=%g, fps=%g, fpns=%g, prs=%g, prns=%g,"
720  " spacing=%g xh=%g y_origin=%g xev=%d, asc=%g, desc=%g,"
721  " body=%g, minsp=%d maxnsp=%d, thr=%d kern=%g sp=%g\n",
725  space_size);
726 }
float descdrop
Definition: blobbox.h:673
int xheight_evidence
Definition: blobbox.h:671
float fixed_pitch
Definition: blobbox.h:664
float spacing
Definition: blobbox.h:669
float space_size
Definition: blobbox.h:680
float pr_nonsp
Definition: blobbox.h:668
float xheight
Definition: blobbox.h:670
float pr_space
Definition: blobbox.h:667
float fp_space
Definition: blobbox.h:665
float kern_size
Definition: blobbox.h:679
DLLSYM void tprintf(const char *format,...)
Definition: tprintf.cpp:37
int32_t space_threshold
Definition: blobbox.h:678
float ascrise
Definition: blobbox.h:672
int32_t min_space
Definition: blobbox.h:676
float body_size
Definition: blobbox.h:674
float fp_nonsp
Definition: blobbox.h:666
int32_t max_nonspace
Definition: blobbox.h:677
PITCH_TYPE pitch_decision
Definition: blobbox.h:663

◆ rep_chars_marked()

bool TO_ROW::rep_chars_marked ( ) const
inline

Definition at line 644 of file blobbox.h.

644  {
645  return num_repeated_sets_ != -1;
646  }

◆ set_limits()

void TO_ROW::set_limits ( float  new_min,
float  new_max 
)
inline

Definition at line 635 of file blobbox.h.

637  { //top of row
638  y_min = new_min;
639  y_max = new_max;
640  }

◆ set_line()

void TO_ROW::set_line ( float  new_m,
float  new_c,
float  new_error 
)
inline

Definition at line 616 of file blobbox.h.

619  {
620  m = new_m;
621  c = new_c;
622  error = new_error;
623  }

◆ set_num_repeated_sets()

void TO_ROW::set_num_repeated_sets ( int  num_sets)
inline

Definition at line 653 of file blobbox.h.

653  {
654  num_repeated_sets_ = num_sets;
655  }

◆ set_parallel_line()

void TO_ROW::set_parallel_line ( float  gradient,
float  new_c,
float  new_error 
)
inline

Definition at line 624 of file blobbox.h.

627  {
628  para_c = new_c;
629  para_error = new_error;
630  credibility =
631  (float) (blobs.length () - kErrorWeight * new_error);
632  y_origin = (float) (new_c / sqrt (1 + gradient * gradient));
633  //real intercept
634  }
static const int kErrorWeight
Definition: blobbox.h:559

Member Data Documentation

◆ all_caps

bool TO_ROW::all_caps

Definition at line 659 of file blobbox.h.

◆ ascrise

float TO_ROW::ascrise

Definition at line 672 of file blobbox.h.

◆ baseline

QSPLINE TO_ROW::baseline

Definition at line 683 of file blobbox.h.

◆ body_size

float TO_ROW::body_size

Definition at line 674 of file blobbox.h.

◆ char_cells

ICOORDELT_LIST TO_ROW::char_cells

Definition at line 682 of file blobbox.h.

◆ descdrop

float TO_ROW::descdrop

Definition at line 673 of file blobbox.h.

◆ fixed_pitch

float TO_ROW::fixed_pitch

Definition at line 664 of file blobbox.h.

◆ fp_nonsp

float TO_ROW::fp_nonsp

Definition at line 666 of file blobbox.h.

◆ fp_space

float TO_ROW::fp_space

Definition at line 665 of file blobbox.h.

◆ kern_size

float TO_ROW::kern_size

Definition at line 679 of file blobbox.h.

◆ kErrorWeight

const int TO_ROW::kErrorWeight = 3
static

Definition at line 559 of file blobbox.h.

◆ max_nonspace

int32_t TO_ROW::max_nonspace

Definition at line 677 of file blobbox.h.

◆ merged

bool TO_ROW::merged

Definition at line 658 of file blobbox.h.

◆ min_space

int32_t TO_ROW::min_space

Definition at line 676 of file blobbox.h.

◆ pitch_decision

PITCH_TYPE TO_ROW::pitch_decision

Definition at line 663 of file blobbox.h.

◆ pr_nonsp

float TO_ROW::pr_nonsp

Definition at line 668 of file blobbox.h.

◆ pr_space

float TO_ROW::pr_space

Definition at line 667 of file blobbox.h.

◆ projection

STATS TO_ROW::projection

Definition at line 684 of file blobbox.h.

◆ projection_left

int16_t TO_ROW::projection_left

Definition at line 661 of file blobbox.h.

◆ projection_right

int16_t TO_ROW::projection_right

Definition at line 662 of file blobbox.h.

◆ rep_words

WERD_LIST TO_ROW::rep_words

Definition at line 681 of file blobbox.h.

◆ space_size

float TO_ROW::space_size

Definition at line 680 of file blobbox.h.

◆ space_threshold

int32_t TO_ROW::space_threshold

Definition at line 678 of file blobbox.h.

◆ spacing

float TO_ROW::spacing

Definition at line 669 of file blobbox.h.

◆ used_dm_model

bool TO_ROW::used_dm_model

Definition at line 660 of file blobbox.h.

◆ xheight

float TO_ROW::xheight

Definition at line 670 of file blobbox.h.

◆ xheight_evidence

int TO_ROW::xheight_evidence

Definition at line 671 of file blobbox.h.


The documentation for this class was generated from the following files: