tesseract  4.00.00dev
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

BOOL8 merged
 
BOOL8 all_caps
 
BOOL8 used_dm_model
 
inT16 projection_left
 
inT16 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 min_space
 
inT32 max_nonspace
 
inT32 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 539 of file blobbox.h.

Constructor & Destructor Documentation

◆ TO_ROW() [1/2]

TO_ROW::TO_ROW ( )
inline

Definition at line 544 of file blobbox.h.

544  {
545  clear();
546  } //empty

◆ TO_ROW() [2/2]

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

Definition at line 684 of file blobbox.cpp.

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

Member Function Documentation

◆ add_blob()

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

Definition at line 728 of file blobbox.cpp.

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

◆ believability()

float TO_ROW::believability ( ) const
inline

Definition at line 581 of file blobbox.h.

581  { //baseline goodness
582  return credibility;
583  }

◆ blob_list()

BLOBNBOX_LIST* TO_ROW::blob_list ( )
inline

Definition at line 595 of file blobbox.h.

595  { //get list
596  return &blobs;
597  }

◆ clear_rep_chars_marked()

void TO_ROW::clear_rep_chars_marked ( )
inline

Definition at line 630 of file blobbox.h.

630  {
631  num_repeated_sets_ = -1;
632  }

◆ compute_vertical_projection()

void TO_ROW::compute_vertical_projection ( )

Definition at line 791 of file blobbox.cpp.

791  { //project whole row
792  TBOX row_box; //bound of row
793  BLOBNBOX *blob; //current blob
794  TBOX blob_box; //bounding box
795  BLOBNBOX_IT blob_it = blob_list ();
796 
797  if (blob_it.empty ())
798  return;
799  row_box = blob_it.data ()->bounding_box ();
800  for (blob_it.mark_cycle_pt (); !blob_it.cycled_list (); blob_it.forward ())
801  row_box += blob_it.data ()->bounding_box ();
802 
804  row_box.right () + PROJECTION_MARGIN);
805  projection_left = row_box.left () - PROJECTION_MARGIN;
807  for (blob_it.mark_cycle_pt (); !blob_it.cycled_list (); blob_it.forward ()) {
808  blob = blob_it.data();
809  if (blob->cblob() != NULL)
811  }
812 }
inT16 projection_left
Definition: blobbox.h:644
C_BLOB * cblob() const
Definition: blobbox.h:253
inT16 left() const
Definition: rect.h:68
void vertical_cblob_projection(C_BLOB *blob, STATS *stats)
Definition: blobbox.cpp:863
Definition: rect.h:30
inT16 right() const
Definition: rect.h:75
STATS projection
Definition: blobbox.h:667
#define PROJECTION_MARGIN
Definition: blobbox.cpp:31
inT16 projection_right
Definition: blobbox.h:645
BLOBNBOX_LIST * blob_list()
Definition: blobbox.h:595
bool set_range(inT32 min_bucket_value, inT32 max_bucket_value_plus_1)
Definition: statistc.cpp:62

◆ initial_min_y()

float TO_ROW::initial_min_y ( ) const
inline

Definition at line 563 of file blobbox.h.

563  {
564  return initial_y_min;
565  }

◆ insert_blob()

void TO_ROW::insert_blob ( BLOBNBOX blob)

Definition at line 764 of file blobbox.cpp.

766  {
767  BLOBNBOX_IT it = &blobs; //list of blobs
768 
769  if (it.empty ())
770  it.add_before_then_move (blob);
771  else {
772  it.mark_cycle_pt ();
773  while (!it.cycled_list ()
774  && it.data ()->bounding_box ().left () <=
775  blob->bounding_box ().left ())
776  it.forward ();
777  if (it.cycled_list ())
778  it.add_to_end (blob);
779  else
780  it.add_before_stay_put (blob);
781  }
782 }
inT16 left() const
Definition: rect.h:68
const TBOX & bounding_box() const
Definition: blobbox.h:215

◆ intercept()

float TO_ROW::intercept ( ) const
inline

Definition at line 584 of file blobbox.h.

584  { //real parallel_c
585  return y_origin;
586  }

◆ line_c()

float TO_ROW::line_c ( ) const
inline

Definition at line 569 of file blobbox.h.

569  {
570  return c;
571  }

◆ line_error()

float TO_ROW::line_error ( ) const
inline

Definition at line 572 of file blobbox.h.

572  {
573  return error;
574  }

◆ line_m()

float TO_ROW::line_m ( ) const
inline

Definition at line 566 of file blobbox.h.

566  { //access to line fit
567  return m;
568  }

◆ max_y()

float TO_ROW::max_y ( ) const
inline

Definition at line 554 of file blobbox.h.

554  { //access function
555  return y_max;
556  }

◆ mean_y()

float TO_ROW::mean_y ( ) const
inline

Definition at line 560 of file blobbox.h.

560  {
561  return (y_min + y_max) / 2.0f;
562  }

◆ min_y()

float TO_ROW::min_y ( ) const
inline

Definition at line 557 of file blobbox.h.

557  {
558  return y_min;
559  }

◆ num_repeated_sets()

int TO_ROW::num_repeated_sets ( ) const
inline

Definition at line 633 of file blobbox.h.

633  {
634  return num_repeated_sets_;
635  }

◆ parallel_c()

float TO_ROW::parallel_c ( ) const
inline

Definition at line 575 of file blobbox.h.

575  {
576  return para_c;
577  }

◆ parallel_error()

float TO_ROW::parallel_error ( ) const
inline

Definition at line 578 of file blobbox.h.

578  {
579  return para_error;
580  }

◆ print()

void TO_ROW::print ( ) const

Definition at line 712 of file blobbox.cpp.

712  {
713  tprintf("pitch=%d, fp=%g, fps=%g, fpns=%g, prs=%g, prns=%g,"
714  " spacing=%g xh=%g y_origin=%g xev=%d, asc=%g, desc=%g,"
715  " body=%g, minsp=%d maxnsp=%d, thr=%d kern=%g sp=%g\n",
719  space_size);
720 }
float pr_nonsp
Definition: blobbox.h:651
int xheight_evidence
Definition: blobbox.h:654
inT32 max_nonspace
Definition: blobbox.h:660
PITCH_TYPE pitch_decision
Definition: blobbox.h:646
float kern_size
Definition: blobbox.h:662
float xheight
Definition: blobbox.h:653
float descdrop
Definition: blobbox.h:656
float space_size
Definition: blobbox.h:663
inT32 space_threshold
Definition: blobbox.h:661
float fp_space
Definition: blobbox.h:648
#define tprintf(...)
Definition: tprintf.h:31
float fixed_pitch
Definition: blobbox.h:647
float body_size
Definition: blobbox.h:657
float pr_space
Definition: blobbox.h:650
inT32 min_space
Definition: blobbox.h:659
float fp_nonsp
Definition: blobbox.h:649
float spacing
Definition: blobbox.h:652
float ascrise
Definition: blobbox.h:655

◆ rep_chars_marked()

bool TO_ROW::rep_chars_marked ( ) const
inline

Definition at line 627 of file blobbox.h.

627  {
628  return num_repeated_sets_ != -1;
629  }

◆ set_limits()

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

Definition at line 618 of file blobbox.h.

620  { //top of row
621  y_min = new_min;
622  y_max = new_max;
623  }

◆ set_line()

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

Definition at line 599 of file blobbox.h.

602  {
603  m = new_m;
604  c = new_c;
605  error = new_error;
606  }

◆ set_num_repeated_sets()

void TO_ROW::set_num_repeated_sets ( int  num_sets)
inline

Definition at line 636 of file blobbox.h.

636  {
637  num_repeated_sets_ = num_sets;
638  }

◆ set_parallel_line()

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

Definition at line 607 of file blobbox.h.

610  {
611  para_c = new_c;
612  para_error = new_error;
613  credibility =
614  (float) (blobs.length () - kErrorWeight * new_error);
615  y_origin = (float) (new_c / sqrt (1 + gradient * gradient));
616  //real intercept
617  }
static const int kErrorWeight
Definition: blobbox.h:542

Member Data Documentation

◆ all_caps

BOOL8 TO_ROW::all_caps

Definition at line 642 of file blobbox.h.

◆ ascrise

float TO_ROW::ascrise

Definition at line 655 of file blobbox.h.

◆ baseline

QSPLINE TO_ROW::baseline

Definition at line 666 of file blobbox.h.

◆ body_size

float TO_ROW::body_size

Definition at line 657 of file blobbox.h.

◆ char_cells

ICOORDELT_LIST TO_ROW::char_cells

Definition at line 665 of file blobbox.h.

◆ descdrop

float TO_ROW::descdrop

Definition at line 656 of file blobbox.h.

◆ fixed_pitch

float TO_ROW::fixed_pitch

Definition at line 647 of file blobbox.h.

◆ fp_nonsp

float TO_ROW::fp_nonsp

Definition at line 649 of file blobbox.h.

◆ fp_space

float TO_ROW::fp_space

Definition at line 648 of file blobbox.h.

◆ kern_size

float TO_ROW::kern_size

Definition at line 662 of file blobbox.h.

◆ kErrorWeight

const int TO_ROW::kErrorWeight = 3
static

Definition at line 542 of file blobbox.h.

◆ max_nonspace

inT32 TO_ROW::max_nonspace

Definition at line 660 of file blobbox.h.

◆ merged

BOOL8 TO_ROW::merged

Definition at line 641 of file blobbox.h.

◆ min_space

inT32 TO_ROW::min_space

Definition at line 659 of file blobbox.h.

◆ pitch_decision

PITCH_TYPE TO_ROW::pitch_decision

Definition at line 646 of file blobbox.h.

◆ pr_nonsp

float TO_ROW::pr_nonsp

Definition at line 651 of file blobbox.h.

◆ pr_space

float TO_ROW::pr_space

Definition at line 650 of file blobbox.h.

◆ projection

STATS TO_ROW::projection

Definition at line 667 of file blobbox.h.

◆ projection_left

inT16 TO_ROW::projection_left

Definition at line 644 of file blobbox.h.

◆ projection_right

inT16 TO_ROW::projection_right

Definition at line 645 of file blobbox.h.

◆ rep_words

WERD_LIST TO_ROW::rep_words

Definition at line 664 of file blobbox.h.

◆ space_size

float TO_ROW::space_size

Definition at line 663 of file blobbox.h.

◆ space_threshold

inT32 TO_ROW::space_threshold

Definition at line 661 of file blobbox.h.

◆ spacing

float TO_ROW::spacing

Definition at line 652 of file blobbox.h.

◆ used_dm_model

BOOL8 TO_ROW::used_dm_model

Definition at line 643 of file blobbox.h.

◆ xheight

float TO_ROW::xheight

Definition at line 653 of file blobbox.h.

◆ xheight_evidence

int TO_ROW::xheight_evidence

Definition at line 654 of file blobbox.h.


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