tesseract 4.1.1
Loading...
Searching...
No Matches
blkocc.h File Reference
#include "params.h"
#include "elst.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)))
 
#define RANGE_OVERLAPS_BAND(band_max, band_min, range_max, range_min)   (((range_max) >= (band_min)) && ((range_min) < (band_max)))
 
#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

bool test_underline (bool testing_on, C_BLOB *blob, int16_t baseline, int16_t 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

◆ DOT_BAND

#define DOT_BAND   0

Definition at line 225 of file blkocc.h.

◆ END_OF_WERD_CODE

#define END_OF_WERD_CODE   255

Definition at line 229 of file blkocc.h.

◆ MAX_NUM_BANDS

#define MAX_NUM_BANDS   5

Definition at line 220 of file blkocc.h.

◆ NO_LOWER_LIMIT

#define NO_LOWER_LIMIT   -9999

Definition at line 222 of file blkocc.h.

◆ NO_UPPER_LIMIT

#define NO_UPPER_LIMIT   9999

Definition at line 223 of file blkocc.h.

◆ RANGE_IN_BAND

#define RANGE_IN_BAND (   band_max,
  band_min,
  range_max,
  range_min 
)    (((range_min) >= (band_min)) && ((range_max) < (band_max)))

Definition at line 63 of file blkocc.h.

◆ RANGE_OVERLAPS_BAND

#define RANGE_OVERLAPS_BAND (   band_max,
  band_min,
  range_max,
  range_min 
)    (((range_max) >= (band_min)) && ((range_min) < (band_max)))

Definition at line 82 of file blkocc.h.

◆ UNDEFINED_BAND

#define UNDEFINED_BAND   99

Definition at line 221 of file blkocc.h.

Function Documentation

◆ test_underline()

bool test_underline ( bool  testing_on,
C_BLOB blob,
int16_t  baseline,
int16_t  xheight 
)

test_underline

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

Parameters
testing_ondrawing blob
blobblob to test
baselinecoords of baseline
xheightheight of line

Definition at line 48 of file blkocc.cpp.

53 {
54 int16_t occ;
55 int16_t blob_width; //width of blob
56 TBOX blob_box; //bounding box
57 int32_t desc_occ;
58 int32_t x_occ;
59 int32_t asc_occ;
60 STATS projection;
61
62 blob_box = blob->bounding_box ();
63 blob_width = blob->bounding_box ().width ();
64 projection.set_range (blob_box.bottom (), blob_box.top () + 1);
65 if (testing_on) {
66 // blob->plot(to_win,GOLDENROD,GOLDENROD);
67 // line_color_index(to_win,GOLDENROD);
68 // move2d(to_win,blob_box.left(),baseline);
69 // draw2d(to_win,blob_box.right(),baseline);
70 // move2d(to_win,blob_box.left(),baseline+xheight);
71 // draw2d(to_win,blob_box.right(),baseline+xheight);
73 ("Testing underline on blob at (%d,%d)->(%d,%d), base=%d\nOccs:",
74 blob->bounding_box ().left (), blob->bounding_box ().bottom (),
75 blob->bounding_box ().right (), blob->bounding_box ().top (),
76 baseline);
77 }
78 horizontal_cblob_projection(blob, &projection);
79 desc_occ = 0;
80 for (occ = blob_box.bottom (); occ < baseline; occ++)
81 if (occ <= blob_box.top () && projection.pile_count (occ) > desc_occ)
82 //max in region
83 desc_occ = projection.pile_count (occ);
84 x_occ = 0;
85 for (occ = baseline; occ <= baseline + xheight; occ++)
86 if (occ >= blob_box.bottom () && occ <= blob_box.top ()
87 && projection.pile_count (occ) > x_occ)
88 //max in region
89 x_occ = projection.pile_count (occ);
90 asc_occ = 0;
91 for (occ = baseline + xheight + 1; occ <= blob_box.top (); occ++)
92 if (occ >= blob_box.bottom () && projection.pile_count (occ) > asc_occ)
93 asc_occ = projection.pile_count (occ);
94 if (testing_on) {
95 tprintf ("%d %d %d\n", desc_occ, x_occ, asc_occ);
96 }
97 if (desc_occ == 0 && x_occ == 0 && asc_occ == 0) {
98 tprintf ("Bottom=%d, top=%d, base=%d, x=%d\n",
99 blob_box.bottom (), blob_box.top (), baseline, xheight);
100 projection.print();
101 }
102 if (desc_occ > x_occ + x_occ
103 && desc_occ > blob_width * textord_underline_threshold)
104 return true; //real underline
105 return asc_occ > x_occ + x_occ &&
106 asc_occ > blob_width * textord_underline_threshold; //overline
107 //neither
108}
DLLSYM void tprintf(const char *format,...)
Definition: tprintf.cpp:35
@ baseline
Definition: mfoutline.h:63
double textord_underline_threshold
Definition: blkocc.cpp:33
Definition: rect.h:34
int16_t top() const
Definition: rect.h:58
int16_t width() const
Definition: rect.h:115
int16_t left() const
Definition: rect.h:72
int16_t bottom() const
Definition: rect.h:65
int16_t right() const
Definition: rect.h:79
Definition: statistc.h:31
int32_t pile_count(int32_t value) const
Definition: statistc.h:76
bool set_range(int32_t min_bucket_value, int32_t max_bucket_value_plus_1)
Definition: statistc.cpp:56
void print() const
Definition: statistc.cpp:526
TBOX bounding_box() const
Definition: stepblob.cpp:253

Variable Documentation

◆ blockocc_asc_height

int blockocc_asc_height = 255
extern

"Ascender height after normalisation"

◆ blockocc_band_count

int blockocc_band_count = 4
extern

"Number of bands used"

◆ blockocc_desc_height

int blockocc_desc_height = 0
extern

"Descender height after normalisation"

◆ blockocc_show_result

bool blockocc_show_result = false
extern

"Show intermediate results"

◆ textord_underline_threshold

double textord_underline_threshold = 0.9
extern

"Fraction of width occupied"

Definition at line 33 of file blkocc.cpp.