Tesseract  3.02
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups 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)
 
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 516 of file blobbox.h.

Constructor & Destructor Documentation

TO_ROW::TO_ROW ( )
inline

Definition at line 521 of file blobbox.h.

521  {
522  clear();
523  } //empty
TO_ROW::TO_ROW ( BLOBNBOX blob,
float  top,
float  bottom,
float  row_size 
)

Definition at line 638 of file blobbox.cpp.

643  {
644  clear();
645  y_min = bottom;
646  y_max = top;
647  initial_y_min = bottom;
648 
649  float diff; //in size
650  BLOBNBOX_IT it = &blobs; //list of blobs
651 
652  it.add_to_end (blob);
653  diff = top - bottom - row_size;
654  if (diff > 0) {
655  y_max -= diff / 2;
656  y_min += diff / 2;
657  }
658  //very small object
659  else if ((top - bottom) * 3 < row_size) {
660  diff = row_size / 3 + bottom - top;
661  y_max += diff / 2;
662  y_min -= diff / 2;
663  }
664 }

Member Function Documentation

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

Definition at line 673 of file blobbox.cpp.

678  {
679  float allowed; //allowed expansion
680  float available; //expansion
681  BLOBNBOX_IT it = &blobs; //list of blobs
682 
683  it.add_to_end (blob);
684  allowed = row_size + y_min - y_max;
685  if (allowed > 0) {
686  available = top > y_max ? top - y_max : 0;
687  if (bottom < y_min)
688  //total available
689  available += y_min - bottom;
690  if (available > 0) {
691  available += available; //do it gradually
692  if (available < allowed)
693  available = allowed;
694  if (bottom < y_min)
695  y_min -= (y_min - bottom) * allowed / available;
696  if (top > y_max)
697  y_max += (top - y_max) * allowed / available;
698  }
699  }
700 }
float TO_ROW::believability ( ) const
inline

Definition at line 557 of file blobbox.h.

557  { //baseline goodness
558  return credibility;
559  }
BLOBNBOX_LIST* TO_ROW::blob_list ( )
inline

Definition at line 571 of file blobbox.h.

571  { //get list
572  return &blobs;
573  }
void TO_ROW::clear_rep_chars_marked ( )
inline

Definition at line 606 of file blobbox.h.

606  {
607  num_repeated_sets_ = -1;
608  }
void TO_ROW::compute_vertical_projection ( )

Definition at line 736 of file blobbox.cpp.

736  { //project whole row
737  TBOX row_box; //bound of row
738  BLOBNBOX *blob; //current blob
739  TBOX blob_box; //bounding box
740  BLOBNBOX_IT blob_it = blob_list ();
741 
742  if (blob_it.empty ())
743  return;
744  row_box = blob_it.data ()->bounding_box ();
745  for (blob_it.mark_cycle_pt (); !blob_it.cycled_list (); blob_it.forward ())
746  row_box += blob_it.data ()->bounding_box ();
747 
749  row_box.right () + PROJECTION_MARGIN);
750  projection_left = row_box.left () - PROJECTION_MARGIN;
752  for (blob_it.mark_cycle_pt (); !blob_it.cycled_list (); blob_it.forward ()) {
753  blob = blob_it.data();
754  if (blob->cblob() != NULL)
756  }
757 }
STATS projection
Definition: blobbox.h:643
C_BLOB * cblob() const
Definition: blobbox.h:245
#define NULL
Definition: host.h:144
inT16 left() const
Definition: rect.h:67
Definition: rect.h:29
inT16 right() const
Definition: rect.h:74
inT16 projection_right
Definition: blobbox.h:621
inT16 projection_left
Definition: blobbox.h:620
void vertical_cblob_projection(C_BLOB *blob, STATS *stats)
Definition: blobbox.cpp:808
bool set_range(inT32 min_bucket_value, inT32 max_bucket_value_plus_1)
Definition: statistc.cpp:61
#define PROJECTION_MARGIN
Definition: blobbox.cpp:29
BLOBNBOX_LIST * blob_list()
Definition: blobbox.h:571
float TO_ROW::initial_min_y ( ) const
inline

Definition at line 539 of file blobbox.h.

539  {
540  return initial_y_min;
541  }
void TO_ROW::insert_blob ( BLOBNBOX blob)

Definition at line 709 of file blobbox.cpp.

711  {
712  BLOBNBOX_IT it = &blobs; //list of blobs
713 
714  if (it.empty ())
715  it.add_before_then_move (blob);
716  else {
717  it.mark_cycle_pt ();
718  while (!it.cycled_list ()
719  && it.data ()->bounding_box ().left () <=
720  blob->bounding_box ().left ())
721  it.forward ();
722  if (it.cycled_list ())
723  it.add_to_end (blob);
724  else
725  it.add_before_stay_put (blob);
726  }
727 }
const TBOX & bounding_box() const
Definition: blobbox.h:208
inT16 left() const
Definition: rect.h:67
float TO_ROW::intercept ( ) const
inline

Definition at line 560 of file blobbox.h.

560  { //real parallel_c
561  return y_origin;
562  }
float TO_ROW::line_c ( ) const
inline

Definition at line 545 of file blobbox.h.

545  {
546  return c;
547  }
float TO_ROW::line_error ( ) const
inline

Definition at line 548 of file blobbox.h.

548  {
549  return error;
550  }
float TO_ROW::line_m ( ) const
inline

Definition at line 542 of file blobbox.h.

542  { //access to line fit
543  return m;
544  }
float TO_ROW::max_y ( ) const
inline

Definition at line 530 of file blobbox.h.

530  { //access function
531  return y_max;
532  }
float TO_ROW::mean_y ( ) const
inline

Definition at line 536 of file blobbox.h.

536  {
537  return (y_min + y_max) / 2.0f;
538  }
float TO_ROW::min_y ( ) const
inline

Definition at line 533 of file blobbox.h.

533  {
534  return y_min;
535  }
int TO_ROW::num_repeated_sets ( ) const
inline

Definition at line 609 of file blobbox.h.

609  {
610  return num_repeated_sets_;
611  }
float TO_ROW::parallel_c ( ) const
inline

Definition at line 551 of file blobbox.h.

551  {
552  return para_c;
553  }
float TO_ROW::parallel_error ( ) const
inline

Definition at line 554 of file blobbox.h.

554  {
555  return para_error;
556  }
bool TO_ROW::rep_chars_marked ( ) const
inline

Definition at line 603 of file blobbox.h.

603  {
604  return num_repeated_sets_ != -1;
605  }
void TO_ROW::set_limits ( float  new_min,
float  new_max 
)
inline

Definition at line 594 of file blobbox.h.

596  { //top of row
597  y_min = new_min;
598  y_max = new_max;
599  }
void TO_ROW::set_line ( float  new_m,
float  new_c,
float  new_error 
)
inline

Definition at line 575 of file blobbox.h.

578  {
579  m = new_m;
580  c = new_c;
581  error = new_error;
582  }
void TO_ROW::set_num_repeated_sets ( int  num_sets)
inline

Definition at line 612 of file blobbox.h.

612  {
613  num_repeated_sets_ = num_sets;
614  }
void TO_ROW::set_parallel_line ( float  gradient,
float  new_c,
float  new_error 
)
inline

Definition at line 583 of file blobbox.h.

586  {
587  para_c = new_c;
588  para_error = new_error;
589  credibility =
590  (float) (blobs.length () - kErrorWeight * new_error);
591  y_origin = (float) (new_c / sqrt (1 + gradient * gradient));
592  //real intercept
593  }
static const int kErrorWeight
Definition: blobbox.h:519

Member Data Documentation

BOOL8 TO_ROW::all_caps

Definition at line 618 of file blobbox.h.

float TO_ROW::ascrise

Definition at line 631 of file blobbox.h.

QSPLINE TO_ROW::baseline

Definition at line 642 of file blobbox.h.

float TO_ROW::body_size

Definition at line 633 of file blobbox.h.

ICOORDELT_LIST TO_ROW::char_cells

Definition at line 641 of file blobbox.h.

float TO_ROW::descdrop

Definition at line 632 of file blobbox.h.

float TO_ROW::fixed_pitch

Definition at line 623 of file blobbox.h.

float TO_ROW::fp_nonsp

Definition at line 625 of file blobbox.h.

float TO_ROW::fp_space

Definition at line 624 of file blobbox.h.

float TO_ROW::kern_size

Definition at line 638 of file blobbox.h.

const int TO_ROW::kErrorWeight = 3
static

Definition at line 519 of file blobbox.h.

inT32 TO_ROW::max_nonspace

Definition at line 636 of file blobbox.h.

BOOL8 TO_ROW::merged

Definition at line 617 of file blobbox.h.

inT32 TO_ROW::min_space

Definition at line 635 of file blobbox.h.

PITCH_TYPE TO_ROW::pitch_decision

Definition at line 622 of file blobbox.h.

float TO_ROW::pr_nonsp

Definition at line 627 of file blobbox.h.

float TO_ROW::pr_space

Definition at line 626 of file blobbox.h.

STATS TO_ROW::projection

Definition at line 643 of file blobbox.h.

inT16 TO_ROW::projection_left

Definition at line 620 of file blobbox.h.

inT16 TO_ROW::projection_right

Definition at line 621 of file blobbox.h.

WERD_LIST TO_ROW::rep_words

Definition at line 640 of file blobbox.h.

float TO_ROW::space_size

Definition at line 639 of file blobbox.h.

inT32 TO_ROW::space_threshold

Definition at line 637 of file blobbox.h.

float TO_ROW::spacing

Definition at line 628 of file blobbox.h.

BOOL8 TO_ROW::used_dm_model

Definition at line 619 of file blobbox.h.

float TO_ROW::xheight

Definition at line 629 of file blobbox.h.

int TO_ROW::xheight_evidence

Definition at line 630 of file blobbox.h.


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