Tesseract  3.02
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
blkocc.h File Reference
#include "params.h"
#include "elst.h"
#include "notdll.h"

Go to the source code of this file.

Classes

class  REGION_OCC
 
class  BAND
 

Macros

#define RANGE_IN_BAND(band_max, band_min, range_max, range_min)   ( ((range_min) >= (band_min)) && ((range_max) < (band_max)) ) ? TRUE : FALSE
 
#define RANGE_OVERLAPS_BAND(band_max, band_min, range_max, range_min)   ( ((range_max) >= (band_min)) && ((range_min) < (band_max)) ) ? TRUE : FALSE
 
#define MAX_NUM_BANDS   5
 
#define UNDEFINED_BAND   99
 
#define NO_LOWER_LIMIT   -9999
 
#define NO_UPPER_LIMIT   9999
 
#define DOT_BAND   0
 
#define END_OF_WERD_CODE   255
 

Functions

BOOL8 test_underline (BOOL8 testing_on, C_BLOB *blob, inT16 baseline, inT16 xheight)
 

Variables

bool blockocc_show_result = FALSE
 
int blockocc_desc_height = 0
 
int blockocc_asc_height = 255
 
int blockocc_band_count = 4
 
double textord_underline_threshold = 0.9
 

Macro Definition Documentation

#define DOT_BAND   0

Definition at line 243 of file blkocc.h.

#define END_OF_WERD_CODE   255

Definition at line 247 of file blkocc.h.

#define MAX_NUM_BANDS   5

Definition at line 238 of file blkocc.h.

#define NO_LOWER_LIMIT   -9999

Definition at line 240 of file blkocc.h.

#define NO_UPPER_LIMIT   9999

Definition at line 241 of file blkocc.h.

#define RANGE_IN_BAND (   band_max,
  band_min,
  range_max,
  range_min 
)    ( ((range_min) >= (band_min)) && ((range_max) < (band_max)) ) ? TRUE : FALSE

Definition at line 71 of file blkocc.h.

#define RANGE_OVERLAPS_BAND (   band_max,
  band_min,
  range_max,
  range_min 
)    ( ((range_max) >= (band_min)) && ((range_min) < (band_max)) ) ? TRUE : FALSE

Definition at line 90 of file blkocc.h.

#define UNDEFINED_BAND   99

Definition at line 239 of file blkocc.h.

Function Documentation

BOOL8 test_underline ( BOOL8  testing_on,
C_BLOB blob,
inT16  baseline,
inT16  xheight 
)

test_underline

Check to see if the blob is an underline. Return TRUE if it is.

Definition at line 55 of file blkocc.cpp.

60  {
61  inT16 occ;
62  inT16 blob_width; //width of blob
63  TBOX blob_box; //bounding box
64  inT32 desc_occ;
65  inT32 x_occ;
66  inT32 asc_occ;
67  STATS projection;
68 
69  blob_box = blob->bounding_box ();
70  blob_width = blob->bounding_box ().width ();
71  projection.set_range (blob_box.bottom (), blob_box.top () + 1);
72  if (testing_on) {
73  // blob->plot(to_win,GOLDENROD,GOLDENROD);
74  // line_color_index(to_win,GOLDENROD);
75  // move2d(to_win,blob_box.left(),baseline);
76  // draw2d(to_win,blob_box.right(),baseline);
77  // move2d(to_win,blob_box.left(),baseline+xheight);
78  // draw2d(to_win,blob_box.right(),baseline+xheight);
79  tprintf
80  ("Testing underline on blob at (%d,%d)->(%d,%d), base=%d\nOccs:",
81  blob->bounding_box ().left (), blob->bounding_box ().bottom (),
82  blob->bounding_box ().right (), blob->bounding_box ().top (),
83  baseline);
84  }
85  horizontal_cblob_projection(blob, &projection);
86  desc_occ = 0;
87  for (occ = blob_box.bottom (); occ < baseline; occ++)
88  if (occ <= blob_box.top () && projection.pile_count (occ) > desc_occ)
89  //max in region
90  desc_occ = projection.pile_count (occ);
91  x_occ = 0;
92  for (occ = baseline; occ <= baseline + xheight; occ++)
93  if (occ >= blob_box.bottom () && occ <= blob_box.top ()
94  && projection.pile_count (occ) > x_occ)
95  //max in region
96  x_occ = projection.pile_count (occ);
97  asc_occ = 0;
98  for (occ = baseline + xheight + 1; occ <= blob_box.top (); occ++)
99  if (occ >= blob_box.bottom () && projection.pile_count (occ) > asc_occ)
100  asc_occ = projection.pile_count (occ);
101  if (testing_on) {
102  tprintf ("%d %d %d\n", desc_occ, x_occ, asc_occ);
103  }
104  if (desc_occ == 0 && x_occ == 0 && asc_occ == 0) {
105  tprintf ("Bottom=%d, top=%d, base=%d, x=%d\n",
106  blob_box.bottom (), blob_box.top (), baseline, xheight);
107  projection.print();
108  }
109  if (desc_occ > x_occ + x_occ
110  && desc_occ > blob_width * textord_underline_threshold)
111  return TRUE; //real underline
112  if (asc_occ > x_occ + x_occ
113  && asc_occ > blob_width * textord_underline_threshold)
114  return TRUE; //overline
115  return FALSE; //neither
116 }
double textord_underline_threshold
Definition: blkocc.cpp:40
inT16 left() const
Definition: rect.h:67
int inT32
Definition: host.h:102
inT16 width() const
Definition: rect.h:104
Definition: rect.h:29
#define FALSE
Definition: capi.h:28
inT16 right() const
Definition: rect.h:74
inT32 pile_count(inT32 value) const
Definition: statistc.h:74
inT16 top() const
Definition: rect.h:53
void print() const
Definition: statistc.cpp:446
DLLSYM void tprintf(const char *format,...)
Definition: tprintf.cpp:41
short inT16
Definition: host.h:100
Definition: statistc.h:29
bool set_range(inT32 min_bucket_value, inT32 max_bucket_value_plus_1)
Definition: statistc.cpp:61
TBOX bounding_box()
Definition: stepblob.cpp:192
#define TRUE
Definition: capi.h:27
inT16 bottom() const
Definition: rect.h:60

Variable Documentation

int blockocc_asc_height = 255

"Ascender height after normalisation"

int blockocc_band_count = 4

"Number of bands used"

int blockocc_desc_height = 0

"Descender height after normalisation"

bool blockocc_show_result = FALSE

"Show intermediate results"

double textord_underline_threshold = 0.9

"Fraction of width occupied"

Definition at line 40 of file blkocc.cpp.