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

◆ BlobNeighbourDir

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 };

◆ BlobRegionType

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 };

◆ BlobSpecialTextType

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 };

◆ BlobTextFlowType

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 };

◆ PITCH_TYPE

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 };

◆ TabType

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

◆ box_next()

TBOX box_next ( BLOBNBOX_IT *  it)

Definition at line 631 of file blobbox.cpp.

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

◆ box_next_pre_chopped()

TBOX box_next_pre_chopped ( BLOBNBOX_IT *  it)

Definition at line 660 of file blobbox.cpp.

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

◆ crotate_cblob()

C_BLOB* crotate_cblob ( C_BLOB blob,
FCOORD  rotation 
)

Definition at line 606 of file blobbox.cpp.

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

◆ DirOtherWay()

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

◆ DominatesInMerge()

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 }

◆ find_cblob_hlimits()

void find_cblob_hlimits ( C_BLOB blob,
float  bottomy,
float  topy,
float &  xmin,
float &  xymax 
)

Definition at line 571 of file blobbox.cpp.

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

◆ find_cblob_limits()

void find_cblob_limits ( C_BLOB blob,
float  leftx,
float  rightx,
FCOORD  rotation,
float &  ymin,
float &  ymax 
)

Definition at line 494 of file blobbox.cpp.

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

◆ find_cblob_vlimits()

void find_cblob_vlimits ( C_BLOB blob,
float  leftx,
float  rightx,
float &  ymin,
float &  ymax 
)

Definition at line 534 of file blobbox.cpp.

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

◆ plot_blob_list()

void plot_blob_list ( ScrollView win,
BLOBNBOX_LIST *  list,
ScrollView::Color  body_colour,
ScrollView::Color  child_colour 
)

Definition at line 1082 of file blobbox.cpp.

1085  { // colour of child
1086  BLOBNBOX_IT it = list;
1087  for (it.mark_cycle_pt(); !it.cycled_list(); it.forward()) {
1088  it.data()->plot(win, body_colour, child_colour);
1089  }
1090 }

◆ vertical_cblob_projection()

void vertical_cblob_projection ( C_BLOB blob,
STATS stats 
)

Definition at line 863 of file blobbox.cpp.

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

◆ vertical_coutline_projection()

void vertical_coutline_projection ( C_OUTLINE outline,
STATS stats 
)

Definition at line 883 of file blobbox.cpp.

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

Variable Documentation

◆ textord_error_weight

double textord_error_weight = 3

"Weighting for error in believability"