All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
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::TO_ROW ( )
inline

Definition at line 544 of file blobbox.h.

544  {
545  clear();
546  } //empty
TO_ROW::TO_ROW ( BLOBNBOX blob,
float  top,
float  bottom,
float  row_size 
)

Definition at line 682 of file blobbox.cpp.

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

Member Function Documentation

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

Definition at line 726 of file blobbox.cpp.

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

Definition at line 581 of file blobbox.h.

581  { //baseline goodness
582  return credibility;
583  }
BLOBNBOX_LIST* TO_ROW::blob_list ( )
inline

Definition at line 595 of file blobbox.h.

595  { //get list
596  return &blobs;
597  }
void TO_ROW::clear_rep_chars_marked ( )
inline

Definition at line 630 of file blobbox.h.

630  {
631  num_repeated_sets_ = -1;
632  }
void TO_ROW::compute_vertical_projection ( )

Definition at line 789 of file blobbox.cpp.

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

Definition at line 563 of file blobbox.h.

563  {
564  return initial_y_min;
565  }
void TO_ROW::insert_blob ( BLOBNBOX blob)

Definition at line 762 of file blobbox.cpp.

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

Definition at line 584 of file blobbox.h.

584  { //real parallel_c
585  return y_origin;
586  }
float TO_ROW::line_c ( ) const
inline

Definition at line 569 of file blobbox.h.

569  {
570  return c;
571  }
float TO_ROW::line_error ( ) const
inline

Definition at line 572 of file blobbox.h.

572  {
573  return error;
574  }
float TO_ROW::line_m ( ) const
inline

Definition at line 566 of file blobbox.h.

566  { //access to line fit
567  return m;
568  }
float TO_ROW::max_y ( ) const
inline

Definition at line 554 of file blobbox.h.

554  { //access function
555  return y_max;
556  }
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  }
float TO_ROW::min_y ( ) const
inline

Definition at line 557 of file blobbox.h.

557  {
558  return y_min;
559  }
int TO_ROW::num_repeated_sets ( ) const
inline

Definition at line 633 of file blobbox.h.

633  {
634  return num_repeated_sets_;
635  }
float TO_ROW::parallel_c ( ) const
inline

Definition at line 575 of file blobbox.h.

575  {
576  return para_c;
577  }
float TO_ROW::parallel_error ( ) const
inline

Definition at line 578 of file blobbox.h.

578  {
579  return para_error;
580  }
void TO_ROW::print ( ) const

Definition at line 710 of file blobbox.cpp.

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

Definition at line 627 of file blobbox.h.

627  {
628  return num_repeated_sets_ != -1;
629  }
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  }
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  }
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  }
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

BOOL8 TO_ROW::all_caps

Definition at line 642 of file blobbox.h.

float TO_ROW::ascrise

Definition at line 655 of file blobbox.h.

QSPLINE TO_ROW::baseline

Definition at line 666 of file blobbox.h.

float TO_ROW::body_size

Definition at line 657 of file blobbox.h.

ICOORDELT_LIST TO_ROW::char_cells

Definition at line 665 of file blobbox.h.

float TO_ROW::descdrop

Definition at line 656 of file blobbox.h.

float TO_ROW::fixed_pitch

Definition at line 647 of file blobbox.h.

float TO_ROW::fp_nonsp

Definition at line 649 of file blobbox.h.

float TO_ROW::fp_space

Definition at line 648 of file blobbox.h.

float TO_ROW::kern_size

Definition at line 662 of file blobbox.h.

const int TO_ROW::kErrorWeight = 3
static

Definition at line 542 of file blobbox.h.

inT32 TO_ROW::max_nonspace

Definition at line 660 of file blobbox.h.

BOOL8 TO_ROW::merged

Definition at line 641 of file blobbox.h.

inT32 TO_ROW::min_space

Definition at line 659 of file blobbox.h.

PITCH_TYPE TO_ROW::pitch_decision

Definition at line 646 of file blobbox.h.

float TO_ROW::pr_nonsp

Definition at line 651 of file blobbox.h.

float TO_ROW::pr_space

Definition at line 650 of file blobbox.h.

STATS TO_ROW::projection

Definition at line 667 of file blobbox.h.

inT16 TO_ROW::projection_left

Definition at line 644 of file blobbox.h.

inT16 TO_ROW::projection_right

Definition at line 645 of file blobbox.h.

WERD_LIST TO_ROW::rep_words

Definition at line 664 of file blobbox.h.

float TO_ROW::space_size

Definition at line 663 of file blobbox.h.

inT32 TO_ROW::space_threshold

Definition at line 661 of file blobbox.h.

float TO_ROW::spacing

Definition at line 652 of file blobbox.h.

BOOL8 TO_ROW::used_dm_model

Definition at line 643 of file blobbox.h.

float TO_ROW::xheight

Definition at line 653 of file blobbox.h.

int TO_ROW::xheight_evidence

Definition at line 654 of file blobbox.h.


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