All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
blobbox.h File Reference
#include "clst.h"
#include "elst2.h"
#include "werd.h"
#include "ocrblock.h"
#include "statistc.h"

Go to the source code of this file.

Classes

class  BLOBNBOX
 
class  TO_ROW
 
class  TO_BLOCK
 

Namespaces

 tesseract
 

Enumerations

enum  PITCH_TYPE {
  PITCH_DUNNO, PITCH_DEF_FIXED, PITCH_MAYBE_FIXED, PITCH_DEF_PROP,
  PITCH_MAYBE_PROP, PITCH_CORR_FIXED, PITCH_CORR_PROP
}
 
enum  TabType {
  TT_NONE, TT_DELETED, TT_MAYBE_RAGGED, TT_MAYBE_ALIGNED,
  TT_CONFIRMED, TT_VLINE
}
 
enum  BlobRegionType {
  BRT_NOISE, BRT_HLINE, BRT_VLINE, BRT_RECTIMAGE,
  BRT_POLYIMAGE, BRT_UNKNOWN, BRT_VERT_TEXT, BRT_TEXT,
  BRT_COUNT
}
 
enum  BlobNeighbourDir {
  BND_LEFT, BND_BELOW, BND_RIGHT, BND_ABOVE,
  BND_COUNT
}
 
enum  BlobSpecialTextType {
  BSTT_NONE, BSTT_ITALIC, BSTT_DIGIT, BSTT_MATH,
  BSTT_UNCLEAR, BSTT_SKIP, BSTT_COUNT
}
 
enum  BlobTextFlowType {
  BTFT_NONE, BTFT_NONTEXT, BTFT_NEIGHBOURS, BTFT_CHAIN,
  BTFT_STRONG_CHAIN, BTFT_TEXT_ON_IMAGE, BTFT_LEADER, BTFT_COUNT
}
 

Functions

BlobNeighbourDir DirOtherWay (BlobNeighbourDir dir)
 
bool DominatesInMerge (BlobTextFlowType type1, BlobTextFlowType type2)
 
void find_cblob_limits (C_BLOB *blob, float leftx, float rightx, FCOORD rotation, float &ymin, float &ymax)
 
void find_cblob_vlimits (C_BLOB *blob, float leftx, float rightx, float &ymin, float &ymax)
 
void find_cblob_hlimits (C_BLOB *blob, float bottomy, float topy, float &xmin, float &xymax)
 
C_BLOBcrotate_cblob (C_BLOB *blob, FCOORD rotation)
 
TBOX box_next (BLOBNBOX_IT *it)
 
TBOX box_next_pre_chopped (BLOBNBOX_IT *it)
 
void vertical_cblob_projection (C_BLOB *blob, STATS *stats)
 
void vertical_coutline_projection (C_OUTLINE *outline, STATS *stats)
 
void plot_blob_list (ScrollView *win, BLOBNBOX_LIST *list, ScrollView::Color body_colour, ScrollView::Color child_colour)
 

Variables

double textord_error_weight = 3
 

Enumeration Type Documentation

Enumerator
BND_LEFT 
BND_BELOW 
BND_RIGHT 
BND_ABOVE 
BND_COUNT 

Definition at line 72 of file blobbox.h.

72  {
73  BND_LEFT,
74  BND_BELOW,
75  BND_RIGHT,
76  BND_ABOVE,
77  BND_COUNT
78 };
Enumerator
BRT_NOISE 
BRT_HLINE 
BRT_VLINE 
BRT_RECTIMAGE 
BRT_POLYIMAGE 
BRT_UNKNOWN 
BRT_VERT_TEXT 
BRT_TEXT 
BRT_COUNT 

Definition at line 57 of file blobbox.h.

57  {
58  BRT_NOISE, // Neither text nor image.
59  BRT_HLINE, // Horizontal separator line.
60  BRT_VLINE, // Vertical separator line.
61  BRT_RECTIMAGE, // Rectangular image.
62  BRT_POLYIMAGE, // Non-rectangular image.
63  BRT_UNKNOWN, // Not determined yet.
64  BRT_VERT_TEXT, // Vertical alignment, not necessarily vertically oriented.
65  BRT_TEXT, // Convincing text.
66 
67  BRT_COUNT // Number of possibilities.
68 };
Enumerator
BSTT_NONE 
BSTT_ITALIC 
BSTT_DIGIT 
BSTT_MATH 
BSTT_UNCLEAR 
BSTT_SKIP 
BSTT_COUNT 

Definition at line 81 of file blobbox.h.

81  {
82  BSTT_NONE, // No special.
83  BSTT_ITALIC, // Italic style.
84  BSTT_DIGIT, // Digit symbols.
85  BSTT_MATH, // Mathmatical symobls (not including digit).
86  BSTT_UNCLEAR, // Characters with low recognition rate.
87  BSTT_SKIP, // Characters that we skip labeling (usually too small).
89 };
Enumerator
BTFT_NONE 
BTFT_NONTEXT 
BTFT_NEIGHBOURS 
BTFT_CHAIN 
BTFT_STRONG_CHAIN 
BTFT_TEXT_ON_IMAGE 
BTFT_LEADER 
BTFT_COUNT 

Definition at line 99 of file blobbox.h.

99  {
100  BTFT_NONE, // No text flow set yet.
101  BTFT_NONTEXT, // Flow too poor to be likely text.
102  BTFT_NEIGHBOURS, // Neighbours support flow in this direction.
103  BTFT_CHAIN, // There is a weak chain of text in this direction.
104  BTFT_STRONG_CHAIN, // There is a strong chain of text in this direction.
105  BTFT_TEXT_ON_IMAGE, // There is a strong chain of text on an image.
106  BTFT_LEADER, // Leader dots/dashes etc.
107  BTFT_COUNT
108 };
enum PITCH_TYPE
Enumerator
PITCH_DUNNO 
PITCH_DEF_FIXED 
PITCH_MAYBE_FIXED 
PITCH_DEF_PROP 
PITCH_MAYBE_PROP 
PITCH_CORR_FIXED 
PITCH_CORR_PROP 

Definition at line 29 of file blobbox.h.

30 {
31  PITCH_DUNNO, // insufficient data
32  PITCH_DEF_FIXED, // definitely fixed
33  PITCH_MAYBE_FIXED, // could be
38 };
enum TabType
Enumerator
TT_NONE 
TT_DELETED 
TT_MAYBE_RAGGED 
TT_MAYBE_ALIGNED 
TT_CONFIRMED 
TT_VLINE 

Definition at line 44 of file blobbox.h.

44  {
45  TT_NONE, // Not a tab.
46  TT_DELETED, // Not a tab after detailed analysis.
47  TT_MAYBE_RAGGED, // Initial designation of a tab-stop candidate.
48  TT_MAYBE_ALIGNED, // Initial designation of a tab-stop candidate.
49  TT_CONFIRMED, // Aligned with neighbours.
50  TT_VLINE // Detected as a vertical line.
51 };

Function Documentation

TBOX box_next ( BLOBNBOX_IT *  it)

Definition at line 629 of file blobbox.cpp.

631  {
632  BLOBNBOX *blob; //current blob
633  TBOX result; //total box
634 
635  blob = it->data ();
636  result = blob->bounding_box ();
637  do {
638  it->forward ();
639  blob = it->data ();
640  if (blob->cblob() == NULL)
641  //was pre-chopped
642  result += blob->bounding_box ();
643  }
644  //until next real blob
645  while ((blob->cblob() == NULL) || blob->joined_to_prev());
646  return result;
647 }
bool joined_to_prev() const
Definition: blobbox.h:241
C_BLOB * cblob() const
Definition: blobbox.h:253
Definition: rect.h:30
#define NULL
Definition: host.h:144
const TBOX & bounding_box() const
Definition: blobbox.h:215
TBOX box_next_pre_chopped ( BLOBNBOX_IT *  it)

Definition at line 658 of file blobbox.cpp.

660  {
661  BLOBNBOX *blob; //current blob
662  TBOX result; //total box
663 
664  blob = it->data ();
665  result = blob->bounding_box ();
666  do {
667  it->forward ();
668  blob = it->data ();
669  }
670  //until next real blob
671  while (blob->joined_to_prev ());
672  return result;
673 }
bool joined_to_prev() const
Definition: blobbox.h:241
Definition: rect.h:30
const TBOX & bounding_box() const
Definition: blobbox.h:215
C_BLOB* crotate_cblob ( C_BLOB blob,
FCOORD  rotation 
)

Definition at line 604 of file blobbox.cpp.

607  {
608  C_OUTLINE_LIST out_list; //output outlines
609  //input outlines
610  C_OUTLINE_IT in_it = blob->out_list ();
611  //output outlines
612  C_OUTLINE_IT out_it = &out_list;
613 
614  for (in_it.mark_cycle_pt (); !in_it.cycled_list (); in_it.forward ()) {
615  out_it.add_after_then_move (new C_OUTLINE (in_it.data (), rotation));
616  }
617  return new C_BLOB (&out_list);
618 }
C_OUTLINE_LIST * out_list()
Definition: stepblob.h:64
BlobNeighbourDir DirOtherWay ( BlobNeighbourDir  dir)
inline

Definition at line 91 of file blobbox.h.

91  {
92  return static_cast<BlobNeighbourDir>(dir ^ 2);
93 }
BlobNeighbourDir
Definition: blobbox.h:72
bool DominatesInMerge ( BlobTextFlowType  type1,
BlobTextFlowType  type2 
)
inline

Definition at line 114 of file blobbox.h.

114  {
115  // LEADER always loses.
116  if (type1 == BTFT_LEADER) return false;
117  if (type2 == BTFT_LEADER) return true;
118  // With those out of the way, the ordering of the enum determines the result.
119  return type1 >= type2;
120 }
void find_cblob_hlimits ( C_BLOB blob,
float  bottomy,
float  topy,
float &  xmin,
float &  xymax 
)

Definition at line 569 of file blobbox.cpp.

574  {
575  inT16 stepindex; //current point
576  ICOORD pos; //current coords
577  ICOORD vec; //rotated step
578  C_OUTLINE *outline; //current outline
579  //outlines
580  C_OUTLINE_IT out_it = blob->out_list ();
581 
582  xmin = (float) MAX_INT32;
583  xmax = (float) -MAX_INT32;
584  for (out_it.mark_cycle_pt (); !out_it.cycled_list (); out_it.forward ()) {
585  outline = out_it.data ();
586  pos = outline->start_pos (); //get coords
587  for (stepindex = 0; stepindex < outline->pathlength (); stepindex++) {
588  //inside
589  if (pos.y () >= bottomy && pos.y () <= topy) {
590  UpdateRange(pos.x(), &xmin, &xmax);
591  }
592  vec = outline->step (stepindex);
593  pos += vec; //move to next
594  }
595  }
596 }
const ICOORD & start_pos() const
Definition: coutln.h:146
void UpdateRange(const T1 &x, T2 *lower_bound, T2 *upper_bound)
Definition: helpers.h:125
inT32 pathlength() const
Definition: coutln.h:133
C_OUTLINE_LIST * out_list()
Definition: stepblob.h:64
inT16 y() const
access_function
Definition: points.h:56
#define MAX_INT32
Definition: host.h:120
integer coordinate
Definition: points.h:30
inT16 x() const
access function
Definition: points.h:52
ICOORD step(int index) const
Definition: coutln.h:142
short inT16
Definition: host.h:100
void find_cblob_limits ( C_BLOB blob,
float  leftx,
float  rightx,
FCOORD  rotation,
float &  ymin,
float &  ymax 
)

Definition at line 492 of file blobbox.cpp.

498  {
499  inT16 stepindex; //current point
500  ICOORD pos; //current coords
501  ICOORD vec; //rotated step
502  C_OUTLINE *outline; //current outline
503  //outlines
504  C_OUTLINE_IT out_it = blob->out_list ();
505 
506  ymin = (float) MAX_INT32;
507  ymax = (float) -MAX_INT32;
508  for (out_it.mark_cycle_pt (); !out_it.cycled_list (); out_it.forward ()) {
509  outline = out_it.data ();
510  pos = outline->start_pos (); //get coords
511  pos.rotate (rotation);
512  for (stepindex = 0; stepindex < outline->pathlength (); stepindex++) {
513  //inside
514  if (pos.x () >= leftx && pos.x () <= rightx) {
515  UpdateRange(pos.y(), &ymin, &ymax);
516  }
517  vec = outline->step (stepindex);
518  vec.rotate (rotation);
519  pos += vec; //move to next
520  }
521  }
522 }
const ICOORD & start_pos() const
Definition: coutln.h:146
void UpdateRange(const T1 &x, T2 *lower_bound, T2 *upper_bound)
Definition: helpers.h:125
inT32 pathlength() const
Definition: coutln.h:133
C_OUTLINE_LIST * out_list()
Definition: stepblob.h:64
void rotate(const FCOORD &vec)
Definition: ipoints.h:241
inT16 y() const
access_function
Definition: points.h:56
#define MAX_INT32
Definition: host.h:120
integer coordinate
Definition: points.h:30
inT16 x() const
access function
Definition: points.h:52
ICOORD step(int index) const
Definition: coutln.h:142
short inT16
Definition: host.h:100
void find_cblob_vlimits ( C_BLOB blob,
float  leftx,
float  rightx,
float &  ymin,
float &  ymax 
)

Definition at line 532 of file blobbox.cpp.

537  {
538  inT16 stepindex; //current point
539  ICOORD pos; //current coords
540  ICOORD vec; //rotated step
541  C_OUTLINE *outline; //current outline
542  //outlines
543  C_OUTLINE_IT out_it = blob->out_list ();
544 
545  ymin = (float) MAX_INT32;
546  ymax = (float) -MAX_INT32;
547  for (out_it.mark_cycle_pt (); !out_it.cycled_list (); out_it.forward ()) {
548  outline = out_it.data ();
549  pos = outline->start_pos (); //get coords
550  for (stepindex = 0; stepindex < outline->pathlength (); stepindex++) {
551  //inside
552  if (pos.x () >= leftx && pos.x () <= rightx) {
553  UpdateRange(pos.y(), &ymin, &ymax);
554  }
555  vec = outline->step (stepindex);
556  pos += vec; //move to next
557  }
558  }
559 }
const ICOORD & start_pos() const
Definition: coutln.h:146
void UpdateRange(const T1 &x, T2 *lower_bound, T2 *upper_bound)
Definition: helpers.h:125
inT32 pathlength() const
Definition: coutln.h:133
C_OUTLINE_LIST * out_list()
Definition: stepblob.h:64
inT16 y() const
access_function
Definition: points.h:56
#define MAX_INT32
Definition: host.h:120
integer coordinate
Definition: points.h:30
inT16 x() const
access function
Definition: points.h:52
ICOORD step(int index) const
Definition: coutln.h:142
short inT16
Definition: host.h:100
void plot_blob_list ( ScrollView win,
BLOBNBOX_LIST *  list,
ScrollView::Color  body_colour,
ScrollView::Color  child_colour 
)

Definition at line 1080 of file blobbox.cpp.

1083  { // colour of child
1084  BLOBNBOX_IT it = list;
1085  for (it.mark_cycle_pt(); !it.cycled_list(); it.forward()) {
1086  it.data()->plot(win, body_colour, child_colour);
1087  }
1088 }
void vertical_cblob_projection ( C_BLOB blob,
STATS stats 
)

Definition at line 861 of file blobbox.cpp.

864  {
865  //outlines of blob
866  C_OUTLINE_IT out_it = blob->out_list ();
867 
868  for (out_it.mark_cycle_pt (); !out_it.cycled_list (); out_it.forward ()) {
869  vertical_coutline_projection (out_it.data (), stats);
870  }
871 }
void vertical_coutline_projection(C_OUTLINE *outline, STATS *stats)
Definition: blobbox.cpp:881
C_OUTLINE_LIST * out_list()
Definition: stepblob.h:64
void vertical_coutline_projection ( C_OUTLINE outline,
STATS stats 
)

Definition at line 881 of file blobbox.cpp.

884  {
885  ICOORD pos; //current point
886  ICOORD step; //edge step
887  inT32 length; //of outline
888  inT16 stepindex; //current step
889  C_OUTLINE_IT out_it = outline->child ();
890 
891  pos = outline->start_pos ();
892  length = outline->pathlength ();
893  for (stepindex = 0; stepindex < length; stepindex++) {
894  step = outline->step (stepindex);
895  if (step.x () > 0) {
896  stats->add (pos.x (), -pos.y ());
897  } else if (step.x () < 0) {
898  stats->add (pos.x () - 1, pos.y ());
899  }
900  pos += step;
901  }
902 
903  for (out_it.mark_cycle_pt (); !out_it.cycled_list (); out_it.forward ()) {
904  vertical_coutline_projection (out_it.data (), stats);
905  }
906 }
void vertical_coutline_projection(C_OUTLINE *outline, STATS *stats)
Definition: blobbox.cpp:881
const ICOORD & start_pos() const
Definition: coutln.h:146
void add(inT32 value, inT32 count)
Definition: statistc.cpp:104
inT32 pathlength() const
Definition: coutln.h:133
inT16 y() const
access_function
Definition: points.h:56
integer coordinate
Definition: points.h:30
inT16 x() const
access function
Definition: points.h:52
ICOORD step(int index) const
Definition: coutln.h:142
C_OUTLINE_LIST * child()
Definition: coutln.h:106
short inT16
Definition: host.h:100
int inT32
Definition: host.h:102

Variable Documentation

double textord_error_weight = 3

"Weighting for error in believability"