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

587  {
588  BLOBNBOX *blob; //current blob
589  TBOX result; //total box
590 
591  blob = it->data ();
592  result = blob->bounding_box ();
593  do {
594  it->forward ();
595  blob = it->data ();
596  if (blob->cblob() == NULL)
597  //was pre-chopped
598  result += blob->bounding_box ();
599  }
600  //until next real blob
601  while ((blob->cblob() == NULL) || blob->joined_to_prev());
602  return result;
603 }
C_BLOB * cblob() const
Definition: blobbox.h:245
const TBOX & bounding_box() const
Definition: blobbox.h:208
#define NULL
Definition: host.h:144
Definition: rect.h:29
bool joined_to_prev() const
Definition: blobbox.h:233
TBOX box_next_pre_chopped ( BLOBNBOX_IT *  it)

Definition at line 614 of file blobbox.cpp.

616  {
617  BLOBNBOX *blob; //current blob
618  TBOX result; //total box
619 
620  blob = it->data ();
621  result = blob->bounding_box ();
622  do {
623  it->forward ();
624  blob = it->data ();
625  }
626  //until next real blob
627  while (blob->joined_to_prev ());
628  return result;
629 }
const TBOX & bounding_box() const
Definition: blobbox.h:208
Definition: rect.h:29
bool joined_to_prev() const
Definition: blobbox.h:233
C_BLOB* crotate_cblob ( C_BLOB blob,
FCOORD  rotation 
)

Definition at line 560 of file blobbox.cpp.

563  {
564  C_OUTLINE_LIST out_list; //output outlines
565  //input outlines
566  C_OUTLINE_IT in_it = blob->out_list ();
567  //output outlines
568  C_OUTLINE_IT out_it = &out_list;
569 
570  for (in_it.mark_cycle_pt (); !in_it.cycled_list (); in_it.forward ()) {
571  out_it.add_after_then_move (new C_OUTLINE (in_it.data (), rotation));
572  }
573  return new C_BLOB (&out_list);
574 }
C_OUTLINE_LIST * out_list()
Definition: stepblob.h:42
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 525 of file blobbox.cpp.

530  {
531  inT16 stepindex; //current point
532  ICOORD pos; //current coords
533  ICOORD vec; //rotated step
534  C_OUTLINE *outline; //current outline
535  //outlines
536  C_OUTLINE_IT out_it = blob->out_list ();
537 
538  xmin = (float) MAX_INT32;
539  xmax = (float) -MAX_INT32;
540  for (out_it.mark_cycle_pt (); !out_it.cycled_list (); out_it.forward ()) {
541  outline = out_it.data ();
542  pos = outline->start_pos (); //get coords
543  for (stepindex = 0; stepindex < outline->pathlength (); stepindex++) {
544  //inside
545  if (pos.y () >= bottomy && pos.y () <= topy) {
546  UpdateRange(pos.x(), &xmin, &xmax);
547  }
548  vec = outline->step (stepindex);
549  pos += vec; //move to next
550  }
551  }
552 }
inT16 x() const
access function
Definition: points.h:52
const ICOORD & start_pos() const
Definition: coutln.h:108
C_OUTLINE_LIST * out_list()
Definition: stepblob.h:42
ICOORD step(inT16 index) const
Definition: coutln.h:120
inT16 y() const
access_function
Definition: points.h:56
#define MAX_INT32
Definition: host.h:120
inT32 pathlength() const
Definition: coutln.h:111
short inT16
Definition: host.h:100
integer coordinate
Definition: points.h:30
void UpdateRange(const T1 &x, T2 *lower_bound, T2 *upper_bound)
Definition: helpers.h:74
void find_cblob_limits ( C_BLOB blob,
float  leftx,
float  rightx,
FCOORD  rotation,
float &  ymin,
float &  ymax 
)

Definition at line 448 of file blobbox.cpp.

454  {
455  inT16 stepindex; //current point
456  ICOORD pos; //current coords
457  ICOORD vec; //rotated step
458  C_OUTLINE *outline; //current outline
459  //outlines
460  C_OUTLINE_IT out_it = blob->out_list ();
461 
462  ymin = (float) MAX_INT32;
463  ymax = (float) -MAX_INT32;
464  for (out_it.mark_cycle_pt (); !out_it.cycled_list (); out_it.forward ()) {
465  outline = out_it.data ();
466  pos = outline->start_pos (); //get coords
467  pos.rotate (rotation);
468  for (stepindex = 0; stepindex < outline->pathlength (); stepindex++) {
469  //inside
470  if (pos.x () >= leftx && pos.x () <= rightx) {
471  UpdateRange(pos.y(), &ymin, &ymax);
472  }
473  vec = outline->step (stepindex);
474  vec.rotate (rotation);
475  pos += vec; //move to next
476  }
477  }
478 }
void rotate(const FCOORD &vec)
Definition: ipoints.h:241
inT16 x() const
access function
Definition: points.h:52
const ICOORD & start_pos() const
Definition: coutln.h:108
C_OUTLINE_LIST * out_list()
Definition: stepblob.h:42
ICOORD step(inT16 index) const
Definition: coutln.h:120
inT16 y() const
access_function
Definition: points.h:56
#define MAX_INT32
Definition: host.h:120
inT32 pathlength() const
Definition: coutln.h:111
short inT16
Definition: host.h:100
integer coordinate
Definition: points.h:30
void UpdateRange(const T1 &x, T2 *lower_bound, T2 *upper_bound)
Definition: helpers.h:74
void find_cblob_vlimits ( C_BLOB blob,
float  leftx,
float  rightx,
float &  ymin,
float &  ymax 
)

Definition at line 488 of file blobbox.cpp.

493  {
494  inT16 stepindex; //current point
495  ICOORD pos; //current coords
496  ICOORD vec; //rotated step
497  C_OUTLINE *outline; //current outline
498  //outlines
499  C_OUTLINE_IT out_it = blob->out_list ();
500 
501  ymin = (float) MAX_INT32;
502  ymax = (float) -MAX_INT32;
503  for (out_it.mark_cycle_pt (); !out_it.cycled_list (); out_it.forward ()) {
504  outline = out_it.data ();
505  pos = outline->start_pos (); //get coords
506  for (stepindex = 0; stepindex < outline->pathlength (); stepindex++) {
507  //inside
508  if (pos.x () >= leftx && pos.x () <= rightx) {
509  UpdateRange(pos.y(), &ymin, &ymax);
510  }
511  vec = outline->step (stepindex);
512  pos += vec; //move to next
513  }
514  }
515 }
inT16 x() const
access function
Definition: points.h:52
const ICOORD & start_pos() const
Definition: coutln.h:108
C_OUTLINE_LIST * out_list()
Definition: stepblob.h:42
ICOORD step(inT16 index) const
Definition: coutln.h:120
inT16 y() const
access_function
Definition: points.h:56
#define MAX_INT32
Definition: host.h:120
inT32 pathlength() const
Definition: coutln.h:111
short inT16
Definition: host.h:100
integer coordinate
Definition: points.h:30
void UpdateRange(const T1 &x, T2 *lower_bound, T2 *upper_bound)
Definition: helpers.h:74
void plot_blob_list ( ScrollView win,
BLOBNBOX_LIST *  list,
ScrollView::Color  body_colour,
ScrollView::Color  child_colour 
)

Definition at line 1014 of file blobbox.cpp.

1017  { // colour of child
1018  BLOBNBOX_IT it = list;
1019  for (it.mark_cycle_pt(); !it.cycled_list(); it.forward()) {
1020  it.data()->plot(win, body_colour, child_colour);
1021  }
1022 }
void vertical_cblob_projection ( C_BLOB blob,
STATS stats 
)

Definition at line 808 of file blobbox.cpp.

811  {
812  //outlines of blob
813  C_OUTLINE_IT out_it = blob->out_list ();
814 
815  for (out_it.mark_cycle_pt (); !out_it.cycled_list (); out_it.forward ()) {
816  vertical_coutline_projection (out_it.data (), stats);
817  }
818 }
void vertical_coutline_projection(C_OUTLINE *outline, STATS *stats)
Definition: blobbox.cpp:828
C_OUTLINE_LIST * out_list()
Definition: stepblob.h:42
void vertical_coutline_projection ( C_OUTLINE outline,
STATS stats 
)

Definition at line 828 of file blobbox.cpp.

831  {
832  ICOORD pos; //current point
833  ICOORD step; //edge step
834  inT32 length; //of outline
835  inT16 stepindex; //current step
836  C_OUTLINE_IT out_it = outline->child ();
837 
838  pos = outline->start_pos ();
839  length = outline->pathlength ();
840  for (stepindex = 0; stepindex < length; stepindex++) {
841  step = outline->step (stepindex);
842  if (step.x () > 0) {
843  stats->add (pos.x (), -pos.y ());
844  } else if (step.x () < 0) {
845  stats->add (pos.x () - 1, pos.y ());
846  }
847  pos += step;
848  }
849 
850  for (out_it.mark_cycle_pt (); !out_it.cycled_list (); out_it.forward ()) {
851  vertical_coutline_projection (out_it.data (), stats);
852  }
853 }
void vertical_coutline_projection(C_OUTLINE *outline, STATS *stats)
Definition: blobbox.cpp:828
inT16 x() const
access function
Definition: points.h:52
const ICOORD & start_pos() const
Definition: coutln.h:108
ICOORD step(inT16 index) const
Definition: coutln.h:120
int inT32
Definition: host.h:102
void add(inT32 value, inT32 count)
Definition: statistc.cpp:103
inT16 y() const
access_function
Definition: points.h:56
inT32 pathlength() const
Definition: coutln.h:111
short inT16
Definition: host.h:100
integer coordinate
Definition: points.h:30
C_OUTLINE_LIST * child()
Definition: coutln.h:80

Variable Documentation

double textord_error_weight = 3

"Weighting for error in believability"