Tesseract 3.02

- Main Page
- Related Pages
- Modules
- Namespaces
- Classes
- Files

- File List
- File Members

All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Classes | Macros | Functions | Variables
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.

{
inT16 occ;
inT16 blob_width; //width of blob
TBOX blob_box; //bounding box
inT32 desc_occ;
inT32 x_occ;
inT32 asc_occ;
STATS projection;
blob_box = blob->bounding_box ();
blob_width = blob->bounding_box ().width ();
projection.set_range (blob_box.bottom (), blob_box.top () + 1);
if (testing_on) {
// blob->plot(to_win,GOLDENROD,GOLDENROD);
// line_color_index(to_win,GOLDENROD);
// move2d(to_win,blob_box.left(),baseline);
// draw2d(to_win,blob_box.right(),baseline);
// move2d(to_win,blob_box.left(),baseline+xheight);
// draw2d(to_win,blob_box.right(),baseline+xheight);
tprintf
("Testing underline on blob at (%d,%d)->(%d,%d), base=%d\nOccs:",
blob->bounding_box ().left (), blob->bounding_box ().bottom (),
blob->bounding_box ().right (), blob->bounding_box ().top (),
baseline);
}
horizontal_cblob_projection(blob, &projection);
desc_occ = 0;
for (occ = blob_box.bottom (); occ < baseline; occ++)
if (occ <= blob_box.top () && projection.pile_count (occ) > desc_occ)
//max in region
desc_occ = projection.pile_count (occ);
x_occ = 0;
for (occ = baseline; occ <= baseline + xheight; occ++)
if (occ >= blob_box.bottom () && occ <= blob_box.top ()
&& projection.pile_count (occ) > x_occ)
//max in region
x_occ = projection.pile_count (occ);
asc_occ = 0;
for (occ = baseline + xheight + 1; occ <= blob_box.top (); occ++)
if (occ >= blob_box.bottom () && projection.pile_count (occ) > asc_occ)
asc_occ = projection.pile_count (occ);
if (testing_on) {
tprintf ("%d %d %d\n", desc_occ, x_occ, asc_occ);
}
if (desc_occ == 0 && x_occ == 0 && asc_occ == 0) {
tprintf ("Bottom=%d, top=%d, base=%d, x=%d\n",
blob_box.bottom (), blob_box.top (), baseline, xheight);
projection.print();
}
if (desc_occ > x_occ + x_occ
&& desc_occ > blob_width * textord_underline_threshold)
return TRUE; //real underline
if (asc_occ > x_occ + x_occ
&& asc_occ > blob_width * textord_underline_threshold)
return TRUE; //overline
return FALSE; //neither
}

## 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.