Fixed name collision with jpeg library

git-svn-id: https://tesseract-ocr.googlecode.com/svn/trunk@158 d0cd1f9f-072b-0410-8dd7-cf729c803f20
This commit is contained in:
theraysmith 2008-04-22 00:34:11 +00:00
parent 7870d67c21
commit 4c6c58e6ea
35 changed files with 1250 additions and 1251 deletions

View File

@ -113,9 +113,9 @@ BOOL8 test_underline( //look for underlines
float baseline, //coords of baseline
float xheight //height of line
) {
INT16 occ;
INT16 blob_width; //width of blob
BOX blob_box; //bounding box
inT16 occ;
inT16 blob_width; //width of blob
TBOX blob_box; //bounding box
float occs[MAX_NUM_BANDS + 1]; //total occupancy
blob_box = blob->bounding_box ();
@ -134,7 +134,7 @@ BOOL8 test_underline( //look for underlines
blob->bounding_box ().right (), blob->bounding_box ().top (),
baseline);
}
block_occ(blob, occs);
block_occ(blob, occs);
if (testing_on) {
for (occ = 0; occ <= MAX_NUM_BANDS; occ++)
tprintf ("%g ", occs[occ]);
@ -160,15 +160,15 @@ BOOL8 test_underline( //look for underlines
BOOL8 test_underline( //look for underlines
BOOL8 testing_on, //drawing blob
C_BLOB *blob, //blob to test
INT16 baseline, //coords of baseline
INT16 xheight //height of line
inT16 baseline, //coords of baseline
inT16 xheight //height of line
) {
INT16 occ;
INT16 blob_width; //width of blob
BOX blob_box; //bounding box
INT32 desc_occ;
INT32 x_occ;
INT32 asc_occ;
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 ();
@ -187,7 +187,7 @@ BOOL8 test_underline( //look for underlines
blob->bounding_box ().right (), blob->bounding_box ().top (),
baseline);
}
horizontal_cblob_projection(blob, &projection);
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)
@ -254,8 +254,8 @@ void horizontal_coutline_projection( //project outlines
) {
ICOORD pos; //current point
ICOORD step; //edge step
INT32 length; //of outline
INT16 stepindex; //current step
inT32 length; //of outline
inT16 stepindex; //current step
C_OUTLINE_IT out_it = outline->child ();
pos = outline->start_pos ();
@ -281,12 +281,12 @@ void set_bands( //init from varibles
float baseline, //top of bottom band
float xheight //height of split band
) {
INT16 int_bl, int_xh; //for band.set
inT16 int_bl, int_xh; //for band.set
bands[DOT_BAND].set (0, 0, 0, 0, 0, 0);
int_bl = (INT16) baseline;
int_xh = (INT16) xheight;
int_bl = (inT16) baseline;
int_xh = (inT16) xheight;
bands[1].set (int_bl, int_bl, int_bl,
NO_LOWER_LIMIT, NO_LOWER_LIMIT, NO_LOWER_LIMIT);
@ -311,8 +311,8 @@ float occs[] //output histogram
REGION_OCC_LIST region_occ_list[MAX_NUM_BANDS + 1];
REGION_OCC_IT region_it; //region iterator
find_transitions(blob, region_occ_list);
compress_region_list(region_occ_list);
find_transitions(blob, region_occ_list);
compress_region_list(region_occ_list);
for (band_index = 0; band_index <= MAX_NUM_BANDS; band_index++) {
occs[band_index] = 0.0f;
region_it.set_to_list (&region_occ_list[band_index]);
@ -328,17 +328,17 @@ float occs[] //output histogram
void find_transitions(PBLOB *blob, //blob to do
REGION_OCC_LIST *region_occ_list) {
OUTLINE_IT outline_it;
BOX box;
TBOX box;
POLYPT_IT pt_it;
FCOORD point1;
FCOORD point2;
FCOORD *entry_pt = &point1;
FCOORD *exit_pt = &point2;
FCOORD *temp_pt;
INT16 increment;
INT16 prev_band;
INT16 band;
INT16 next_band;
inT16 increment;
inT16 prev_band;
inT16 band;
inT16 next_band;
float min_x;
float max_x;
float min_y;
@ -348,7 +348,7 @@ void find_transitions(PBLOB *blob, //blob to do
outline_it = blob->out_list ();
for (outline_it.mark_cycle_pt (); !outline_it.cycled_list ();
outline_it.forward ()) {
find_fbox(&outline_it, &min_x, &min_y, &max_x, &max_y);
find_fbox(&outline_it, &min_x, &min_y, &max_x, &max_y);
if (bands[DOT_BAND].range_in_nominal (max_y, min_y)) {
record_region(DOT_BAND,
@ -399,7 +399,7 @@ void find_transitions(PBLOB *blob, //blob to do
pt_it = outline_it.data ()->polypts ();
find_significant_line(pt_it, &band);
find_significant_line(pt_it, &band);
*entry_pt = pt_it.data ()->pos;
next_region(&pt_it,
band,
@ -469,10 +469,10 @@ void find_transitions(PBLOB *blob, //blob to do
void record_region( //add region on list
INT16 band,
inT16 band,
float new_min,
float new_max,
INT16 region_type,
inT16 region_type,
REGION_OCC_LIST *region_occ_list) {
REGION_OCC_IT it (&(region_occ_list[band]));
@ -509,11 +509,11 @@ void record_region( //add region on list
}
INT16 find_containing_maximal_band( //find range's band
inT16 find_containing_maximal_band( //find range's band
float y1,
float y2,
BOOL8 *doubly_contained) {
INT16 band;
inT16 band;
*doubly_contained = FALSE;
@ -529,7 +529,7 @@ INT16 find_containing_maximal_band( //find range's band
}
void find_significant_line(POLYPT_IT it, INT16 *band) {
void find_significant_line(POLYPT_IT it, inT16 *band) {
/* Look for a line which significantly occupies at least one band. I.e. part
of the line is in the non-margin part of the band. */
@ -547,10 +547,10 @@ void find_significant_line(POLYPT_IT it, INT16 *band) {
}
INT16 find_overlapping_minimal_band( //find range's band
inT16 find_overlapping_minimal_band( //find range's band
float y1,
float y2) {
INT16 band;
inT16 band;
for (band = 1; band <= blockocc_band_count; band++) {
if (bands[band].range_overlaps_minimal (y1, y2))
@ -560,9 +560,9 @@ INT16 find_overlapping_minimal_band( //find range's band
}
INT16 find_region_type(INT16 entry_band,
INT16 current_band,
INT16 exit_band,
inT16 find_region_type(inT16 entry_band,
inT16 current_band,
inT16 exit_band,
float entry_x,
float exit_x) {
if (entry_band > exit_band)
@ -587,8 +587,8 @@ INT16 find_region_type(INT16 entry_band,
void find_trans_point(POLYPT_IT *pt_it,
INT16 current_band,
INT16 next_band,
inT16 current_band,
inT16 next_band,
FCOORD *transition_pt) {
float x1, x2, y1, y2; // points of edge
float gradient; // m in y = mx + c
@ -621,11 +621,11 @@ void find_trans_point(POLYPT_IT *pt_it,
void next_region(POLYPT_IT *start_pt_it,
INT16 start_band,
INT16 *to_band,
inT16 start_band,
inT16 *to_band,
float *min_x,
float *max_x,
INT16 *increment,
inT16 *increment,
FCOORD *exit_pt) {
/*
Given an edge and a band which the edge significantly occupies, find the
@ -639,12 +639,12 @@ void next_region(POLYPT_IT *start_pt_it,
the start of the first region.
*/
INT16 band; //band of current edge
INT16 prev_band = start_band; //band of prev edge
inT16 band; //band of current edge
inT16 prev_band = start_band; //band of prev edge
//edge crossing out
POLYPT_IT last_transition_out_it;
//band it pts to
INT16 last_trans_out_to_band = 0;
inT16 last_trans_out_to_band = 0;
float ext_min_x = 0.0f;
float ext_max_x = 0.0f;
@ -704,9 +704,9 @@ void next_region(POLYPT_IT *start_pt_it,
}
INT16 find_band( // find POINT's band
inT16 find_band( // find POINT's band
float y) {
INT16 band;
inT16 band;
for (band = 1; band <= blockocc_band_count; band++) {
if (bands[band].in_nominal (y))
@ -722,7 +722,7 @@ void compress_region_list( // join open regions
REGION_OCC_IT it (&(region_occ_list[0]));
REGION_OCC *open_right = NULL;
INT16 i = 0;
inT16 i = 0;
for (i = 0; i <= blockocc_band_count; i++) {
it.set_to_list (&(region_occ_list[i]));
@ -801,7 +801,7 @@ void find_fbox(OUTLINE_IT *out_it,
}
void maintain_limits(float *min_x, float *max_x, float x) {
void maintain_limits(float *min_x, float *max_x, float x) {
if (x > *max_x)
*max_x = x;
if (x < *min_x)

View File

@ -53,15 +53,15 @@ class REGION_OCC:public ELIST_LINK
public:
float min_x; //Lowest x in region
float max_x; //Highest x in region
INT16 region_type; //Type of crossing
inT16 region_type; //Type of crossing
REGION_OCC() {
REGION_OCC() {
}; //constructor used
//only in COPIER etc
REGION_OCC( //constructor
float min,
float max,
INT16 region) {
inT16 region) {
min_x = min;
max_x = max;
region_type = region;
@ -77,10 +77,10 @@ class in an include file...
BOOL8 range_in_band[
range within band?
INT16 band_max,
INT16 band_min,
INT16 range_max,
INT16 range_min]
inT16 band_max,
inT16 band_min,
inT16 range_max,
inT16 range_min]
{
if ( (range_min >= band_min) && (range_max < band_max) )
return TRUE;
@ -96,10 +96,10 @@ class in an include file...
BOOL8 range_overlaps_band[
range crosses band?
INT16 band_max,
INT16 band_min,
INT16 range_max,
INT16 range_min]
inT16 band_max,
inT16 band_min,
inT16 range_max,
inT16 range_min]
{
if ( (range_max >= band_min) && (range_min < band_max) )
return TRUE;
@ -130,23 +130,23 @@ have significantly changed bands until it has moved out of the error margin.
class BAND
{
public:
INT16 max_max; //upper max
INT16 max; //nominal max
INT16 min_max; //lower max
INT16 max_min; //upper min
INT16 min; //nominal min
INT16 min_min; //lower min
inT16 max_max; //upper max
inT16 max; //nominal max
inT16 min_max; //lower max
inT16 max_min; //upper min
inT16 min; //nominal min
inT16 min_min; //lower min
BAND() {
BAND() {
} // constructor
void set( // initialise a band
INT16 new_max_max, // upper max
INT16 new_max, // new nominal max
INT16 new_min_max, // new lower max
INT16 new_max_min, // new upper min
INT16 new_min, // new nominal min
INT16 new_min_min) { // new lower min
inT16 new_max_max, // upper max
inT16 new_max, // new nominal max
inT16 new_min_max, // new lower max
inT16 new_max_min, // new upper min
inT16 new_min, // new nominal min
inT16 new_min_min) { // new lower min
max_max = new_max_max;
max = new_max;
min_max = new_min_max;
@ -264,8 +264,8 @@ BOOL8 test_underline( //look for underlines
BOOL8 test_underline( //look for underlines
BOOL8 testing_on, //drawing blob
C_BLOB *blob, //blob to test
INT16 baseline, //coords of baseline
INT16 xheight //height of line
inT16 baseline, //coords of baseline
inT16 xheight //height of line
);
//project outlines
void horizontal_cblob_projection(C_BLOB *blob, //blob to project
@ -283,38 +283,38 @@ void block_occ (PBLOB * blob, //blob to do
float occs[] //output histogram
);
//blob to do
void find_transitions(PBLOB *blob, REGION_OCC_LIST *region_occ_list);
void find_transitions(PBLOB *blob, REGION_OCC_LIST *region_occ_list);
void record_region( //add region on list
INT16 band,
inT16 band,
float new_min,
float new_max,
INT16 region_type,
inT16 region_type,
REGION_OCC_LIST *region_occ_list);
INT16 find_containing_maximal_band( //find range's band
inT16 find_containing_maximal_band( //find range's band
float y1,
float y2,
BOOL8 *doubly_contained);
void find_significant_line(POLYPT_IT it, INT16 *band);
INT16 find_overlapping_minimal_band( //find range's band
void find_significant_line(POLYPT_IT it, inT16 *band);
inT16 find_overlapping_minimal_band( //find range's band
float y1,
float y2);
INT16 find_region_type(INT16 entry_band,
INT16 current_band,
INT16 exit_band,
inT16 find_region_type(inT16 entry_band,
inT16 current_band,
inT16 exit_band,
float entry_x,
float exit_x);
void find_trans_point(POLYPT_IT *pt_it,
INT16 current_band,
INT16 next_band,
inT16 current_band,
inT16 next_band,
FCOORD *transition_pt);
void next_region(POLYPT_IT *start_pt_it,
INT16 start_band,
INT16 *to_band,
inT16 start_band,
inT16 *to_band,
float *min_x,
float *max_x,
INT16 *increment,
inT16 *increment,
FCOORD *exit_pt);
INT16 find_band( // find POINT's band
inT16 find_band( // find POINT's band
float y);
void compress_region_list( // join open regions
REGION_OCC_LIST *region_occ_list);
@ -323,5 +323,5 @@ void find_fbox(OUTLINE_IT *out_it,
float *min_y,
float *max_x,
float *max_y);
void maintain_limits(float *min_x, float *max_x, float x);
void maintain_limits(float *min_x, float *max_x, float x);
#endif

View File

@ -1,8 +1,8 @@
/**********************************************************************
* File: drawedg.c (Formerly drawedge.c)
* Description: Collection of functions to draw things to do with edge detection.
* Author: Ray Smith
* Created: Thu Jun 06 13:29:20 BST 1991
* Author: Ray Smith
* Created: Thu Jun 06 13:29:20 BST 1991
*
* (C) Copyright 1991, Hewlett-Packard Ltd.
** Licensed under the Apache License, Version 2.0 (the "License");
@ -40,9 +40,6 @@ ScrollView* create_edges_window( //make window
//create the window
image_win = new ScrollView (IMAGE_WIN_NAME, IMAGE_XPOS, IMAGE_YPOS, 0, 0, page_tr.x (), page_tr.y ());
#ifdef __MSW32__
set_selection_handler(image_win, win_selection_handler);
#endif
return image_win; //window
}
@ -60,7 +57,7 @@ void draw_raw_edge( //draw the cracks
) {
CRACKEDGE *edgept; //current point
fd->Pen(colour);
fd->Pen(colour);
edgept = start;
fd->SetCursor(edgept->pos.x (), edgept->pos.y ());
do {

View File

@ -55,12 +55,12 @@ void create_to_win( //make features win
ICOORD page_tr //size of page
) {
if (strcmp (to_smdfile.string (), NO_SMD)) {
to_win = new ScrollView (to_smdfile.string (),
to_win = new ScrollView (to_smdfile.string (),
0, 0, page_tr.x () + 1, page_tr.y () + 1,
page_tr.x (), page_tr.y ());
}
else {
to_win = new ScrollView (TO_WIN_NAME,
to_win = new ScrollView (TO_WIN_NAME,
TO_WIN_XPOS, TO_WIN_YPOS, 0, 0,
page_tr.x (), page_tr.y ());
}
@ -121,7 +121,7 @@ void plot_box_list( //make gradients win
) {
BLOBNBOX_IT it = list; //iterator
win->Pen(body_colour);
win->Pen(body_colour);
for (it.mark_cycle_pt (); !it.cycled_list (); it.forward ()) {
it.data ()->bounding_box ().plot (win);
}
@ -152,7 +152,7 @@ void plot_to_row( //draw a row
it.move_to_last ();
right = it.data ()->bounding_box ().right ();
plot_blob_list (to_win, row->blob_list (), colour, ScrollView::BROWN);
to_win->Pen(colour);
to_win->Pen(colour);
plot_pt = FCOORD (left, row->line_m () * left + row->line_c ());
plot_pt.rotate (rotation);
to_win->SetCursor(plot_pt.x (), plot_pt.y ());
@ -171,7 +171,7 @@ void plot_to_row( //draw a row
void plot_parallel_row( //draw a row
TO_ROW *row, //row to draw
float gradient, //gradients of lines
INT32 left, //edge of block
inT32 left, //edge of block
ScrollView::Color colour, //colour to draw in
FCOORD rotation //rotation for line
) {
@ -185,7 +185,7 @@ void plot_parallel_row( //draw a row
it.move_to_last ();
right = it.data ()->bounding_box ().right ();
plot_blob_list (to_win, row->blob_list (), colour, ScrollView::BROWN);
to_win->Pen(colour);
to_win->Pen(colour);
plot_pt = FCOORD (fleft, gradient * left + row->max_y ());
plot_pt.rotate (rotation);
to_win->SetCursor(plot_pt.x (), plot_pt.y ());
@ -210,36 +210,36 @@ void plot_parallel_row( //draw a row
void
draw_occupation ( //draw projection
INT32 xleft, //edge of block
INT32 ybottom, //bottom of block
INT32 min_y, //coordinate limits
INT32 max_y, INT32 occupation[], //projection counts
INT32 thresholds[] //for drop out
inT32 xleft, //edge of block
inT32 ybottom, //bottom of block
inT32 min_y, //coordinate limits
inT32 max_y, inT32 occupation[], //projection counts
inT32 thresholds[] //for drop out
) {
INT32 line_index; //pixel coord
inT32 line_index; //pixel coord
ScrollView::Color colour; //of histogram
float fleft = (float) xleft; //float version
colour = ScrollView::WHITE;
to_win->Pen(colour);
to_win->Pen(colour);
to_win->SetCursor(fleft, (float) ybottom);
for (line_index = min_y; line_index <= max_y; line_index++) {
if (occupation[line_index - min_y] < thresholds[line_index - min_y]) {
if (colour != ScrollView::BLUE) {
colour = ScrollView::BLUE;
to_win->Pen(colour);
to_win->Pen(colour);
}
}
else {
if (colour != ScrollView::WHITE) {
colour = ScrollView::WHITE;
to_win->Pen(colour);
to_win->Pen(colour);
}
}
to_win->DrawTo(fleft + occupation[line_index - min_y] / 10.0, (float) line_index);
}
colour=ScrollView::STEEL_BLUE;
to_win->Pen(colour);
to_win->Pen(colour);
to_win->SetCursor(fleft, (float) ybottom);
for (line_index = min_y; line_index <= max_y; line_index++) {
to_win->DrawTo(fleft + thresholds[line_index - min_y] / 10.0, (float) line_index);
@ -256,7 +256,7 @@ INT32 thresholds[] //for drop out
void draw_meanlines( //draw a block
TO_BLOCK *block, //block to draw
float gradient, //gradients of lines
INT32 left, //edge of block
inT32 left, //edge of block
ScrollView::Color colour, //colour to draw in
FCOORD rotation //rotation for line
) {
@ -266,7 +266,7 @@ void draw_meanlines( //draw a block
TO_ROW *row; //current row
BLOBNBOX_IT blob_it; //blobs
float right; //end of row
to_win->Pen(colour);
to_win->Pen(colour);
for (row_it.mark_cycle_pt (); !row_it.cycled_list (); row_it.forward ()) {
row = row_it.data ();
blob_it.set_to_list (row->blob_list ());
@ -295,15 +295,15 @@ void draw_meanlines( //draw a block
void plot_word_decisions( //draw words
ScrollView* win, //window tro draw in
INT16 pitch, //of block
inT16 pitch, //of block
TO_ROW *row //row to draw
) {
ScrollView::Color colour = ScrollView::MAGENTA; //current colour
ScrollView::Color rect_colour; //fuzzy colour
INT32 prev_x; //end of prev blob
INT16 blob_count; //blobs in word
inT32 prev_x; //end of prev blob
inT16 blob_count; //blobs in word
BLOBNBOX *blob; //current blob
BOX blob_box; //bounding box
TBOX blob_box; //bounding box
//iterator
BLOBNBOX_IT blob_it = row->blob_list ();
BLOBNBOX_IT start_it = blob_it;//word start
@ -336,8 +336,8 @@ void plot_word_decisions( //draw words
rect_colour = ScrollView::GOLDENROD;
else
rect_colour = ScrollView::CORAL;
//fill_color_index(win, rect_colour);
win->Brush(rect_colour);
//fill_color_index(win, rect_colour);
win->Brush(rect_colour);
win->Rectangle (prev_x, blob_box.bottom (),
blob_box.left (), blob_box.top ());
}
@ -371,14 +371,14 @@ void plot_fp_cells( //draw words
ScrollView* win, //window tro draw in
ScrollView::Color colour, //colour of lines
BLOBNBOX_IT *blob_it, //blobs
INT16 pitch, //of block
INT16 blob_count, //no of real blobs
inT16 pitch, //of block
inT16 blob_count, //no of real blobs
STATS *projection, //vertical
INT16 projection_left, //edges //scale factor
INT16 projection_right,
inT16 projection_left, //edges //scale factor
inT16 projection_right,
float projection_scale) {
INT16 occupation; //occupied cells
BOX word_box; //bounding box
inT16 occupation; //occupied cells
TBOX word_box; //bounding box
FPSEGPT_LIST seg_list; //list of cuts
FPSEGPT_IT seg_it;
FPSEGPT *segpt; //current point
@ -417,7 +417,7 @@ void plot_fp_cells2( //draw words
TO_ROW *row, //for location
FPSEGPT_LIST *seg_list //segments to plot
) {
BOX word_box; //bounding box
TBOX word_box; //bounding box
FPSEGPT_IT seg_it = seg_list;
//blobs in row
BLOBNBOX_IT blob_it = row->blob_list ();
@ -451,7 +451,7 @@ void plot_row_cells( //draw words
float xshift, //amount of shift
ICOORDELT_LIST *cells //cells to draw
) {
BOX word_box; //bounding box
TBOX word_box; //bounding box
ICOORDELT_IT cell_it = cells;
//blobs in row
BLOBNBOX_IT blob_it = row->blob_list ();
@ -460,7 +460,7 @@ void plot_row_cells( //draw words
word_box = blob_it.data ()->bounding_box ();
for (blob_it.mark_cycle_pt (); !blob_it.cycled_list ();)
word_box += box_next (&blob_it);
win->Pen(colour);
win->Pen(colour);
for (cell_it.mark_cycle_pt (); !cell_it.cycled_list (); cell_it.forward ()) {
cell = cell_it.data ();
win->Line(cell->x () + xshift, word_box.bottom (), cell->x () + xshift, word_box.top ());

View File

@ -58,38 +58,38 @@ void plot_to_row( //draw a row
void plot_parallel_row( //draw a row
TO_ROW *row, //row to draw
float gradient, //gradients of lines
INT32 left, //edge of block
inT32 left, //edge of block
ScrollView::Color colour, //colour to draw in
FCOORD rotation //rotation for line
);
void draw_occupation ( //draw projection
INT32 xleft, //edge of block
INT32 ybottom, //bottom of block
INT32 min_y, //coordinate limits
INT32 max_y, INT32 occupation[], //projection counts
INT32 thresholds[] //for drop out
inT32 xleft, //edge of block
inT32 ybottom, //bottom of block
inT32 min_y, //coordinate limits
inT32 max_y, inT32 occupation[], //projection counts
inT32 thresholds[] //for drop out
);
void draw_meanlines( //draw a block
TO_BLOCK *block, //block to draw
float gradient, //gradients of lines
INT32 left, //edge of block
inT32 left, //edge of block
ScrollView::Color colour, //colour to draw in
FCOORD rotation //rotation for line
);
void plot_word_decisions( //draw words
ScrollView* win, //window tro draw in
INT16 pitch, //of block
inT16 pitch, //of block
TO_ROW *row //row to draw
);
void plot_fp_cells( //draw words
ScrollView* win, //window tro draw in
ScrollView::Color colour, //colour of lines
BLOBNBOX_IT *blob_it, //blobs
INT16 pitch, //of block
INT16 blob_count, //no of real blobs
inT16 pitch, //of block
inT16 blob_count, //no of real blobs
STATS *projection, //vertical
INT16 projection_left, //edges //scale factor
INT16 projection_right,
inT16 projection_left, //edges //scale factor
inT16 projection_right,
float projection_scale);
void plot_fp_cells2( //draw words
ScrollView* win, //window tro draw in

View File

@ -68,8 +68,8 @@ ICOORD tright): bl (bleft), tr (tright) {
C_OUTLINE_LIST *
OL_BUCKETS::operator () ( //array access
INT16 x, //image coords
INT16 y) {
inT16 x, //image coords
inT16 y) {
return &buckets[(y - bl.y ()) / BUCKETSIZE * bxdim +
(x - bl.x ()) / BUCKETSIZE];
}
@ -81,22 +81,22 @@ INT16 y) {
* Find number of descendants of this outline.
**********************************************************************/
INT32 OL_BUCKETS::count_children( //recursive count
inT32 OL_BUCKETS::count_children( //recursive count
C_OUTLINE *outline, //parent outline
INT32 max_count //max output
inT32 max_count //max output
) {
BOOL8 parent_box; //could it be boxy
INT16 xmin, xmax; //coord limits
INT16 ymin, ymax;
INT16 xindex, yindex; //current bucket
inT16 xmin, xmax; //coord limits
inT16 ymin, ymax;
inT16 xindex, yindex; //current bucket
C_OUTLINE *child; //current child
INT32 child_count; //no of children
INT32 grandchild_count; //no of grandchildren
INT32 parent_area; //potential box
inT32 child_count; //no of children
inT32 grandchild_count; //no of grandchildren
inT32 parent_area; //potential box
FLOAT32 max_parent_area; //potential box
INT32 child_area; //current child
INT32 child_length; //current child
BOX olbox;
inT32 child_area; //current child
inT32 child_length; //current child
TBOX olbox;
C_OUTLINE_IT child_it; //search iterator
olbox = outline->bounding_box ();
@ -202,10 +202,10 @@ void OL_BUCKETS::extract_children( //recursive count
C_OUTLINE *outline, //parent outline
C_OUTLINE_IT *it //destination iterator
) {
INT16 xmin, xmax; //coord limits
INT16 ymin, ymax;
INT16 xindex, yindex; //current bucket
BOX olbox;
inT16 xmin, xmax; //coord limits
inT16 ymin, ymax;
inT16 xindex, yindex; //current bucket
TBOX olbox;
C_OUTLINE_IT child_it; //search iterator
olbox = outline->bounding_box ();
@ -290,7 +290,7 @@ void fill_buckets( //find blobs
C_OUTLINE_LIST *outlines, //outlines in block
OL_BUCKETS *buckets //output buckets
) {
BOX ol_box; //outline box
TBOX ol_box; //outline box
C_OUTLINE_IT out_it = outlines;//iterator
C_OUTLINE_IT bucket_it; //iterator in bucket
C_OUTLINE *outline; //current outline
@ -364,7 +364,7 @@ BOOL8 capture_children( //find children
C_OUTLINE_IT *blob_it //output outlines
) {
C_OUTLINE *outline; //master outline
INT32 child_count; //no of children
inT32 child_count; //no of children
outline = blob_it->data ();
child_count = buckets->count_children (outline, edges_children_count_limit);

View File

@ -41,33 +41,33 @@ class OL_BUCKETS
delete[]buckets;
}
C_OUTLINE_LIST *operator () (//array access
INT16 x, //image coords
INT16 y);
inT16 x, //image coords
inT16 y);
//first non-empty bucket
C_OUTLINE_LIST *start_scan() {
C_OUTLINE_LIST *start_scan() {
for (index = 0; buckets[index].empty () && index < bxdim * bydim - 1;
index++);
return &buckets[index];
}
//next non-empty bucket
C_OUTLINE_LIST *scan_next() {
C_OUTLINE_LIST *scan_next() {
for (; buckets[index].empty () && index < bxdim * bydim - 1; index++);
return &buckets[index];
}
INT32 count_children( //recursive sum
inT32 count_children( //recursive sum
C_OUTLINE *outline, //parent outline
INT32 max_count); //max output
inT32 max_count); //max output
void extract_children( //single level get
C_OUTLINE *outline, //parent outline
C_OUTLINE_IT *it); //destination iterator
private:
C_OUTLINE_LIST * buckets; //array of buckets
INT16 bxdim; //size of array
INT16 bydim;
inT16 bxdim; //size of array
inT16 bydim;
ICOORD bl; //corners
ICOORD tr;
INT32 index; //for extraction scan
inT32 index; //for extraction scan
};
void extract_edges( //find blobs

View File

@ -79,7 +79,7 @@ void complete_edge( //clean and approximate
CRACKEDGE *start //start of loop
) {
ScrollView::Color colour; //colour to draw in
INT16 looplength; //steps in loop
inT16 looplength; //steps in loop
ICOORD botleft; //bounding box
ICOORD topright;
C_OUTLINE *outline; //new outline
@ -117,8 +117,8 @@ ScrollView::Color check_path_legal( //certify outline
) {
int lastchain; //last chain code
int chaindiff; //chain code diff
INT32 length; //length of loop
INT32 chainsum; //sum of chain diffs
inT32 length; //length of loop
inT32 chainsum; //sum of chain diffs
CRACKEDGE *edgept; //current point
const ERRCODE ED_ILLEGAL_SUM = "Illegal sum of chain codes";
@ -168,12 +168,12 @@ ScrollView::Color check_path_legal( //certify outline
* Find the bounding box of the edge loop.
**********************************************************************/
INT16 loop_bounding_box( //get bounding box
inT16 loop_bounding_box( //get bounding box
CRACKEDGE *&start, //edge loop
ICOORD &botleft, //bounding box
ICOORD &topright) {
INT16 length; //length of loop
INT16 leftmost; //on top row
inT16 length; //length of loop
inT16 leftmost; //on top row
CRACKEDGE *edgept; //current point
CRACKEDGE *realstart; //topleft start

View File

@ -59,7 +59,7 @@ void complete_edge( //clean and approximate
ScrollView::Color check_path_legal( //certify outline
CRACKEDGE *start //start of loop
);
INT16 loop_bounding_box( //get bounding box
inT16 loop_bounding_box( //get bounding box
CRACKEDGE *&start, //edge loop
ICOORD &botleft, //bounding box
ICOORD &topright);

View File

@ -51,11 +51,11 @@ ROW *fixed_pitch_words( //find lines
FCOORD rotation //for drawing
) {
BOOL8 bol; //start of line
UINT8 blanks; //in front of word
UINT8 new_blanks; //blanks in empty cell
INT16 chop_coord; //chop boundary
INT16 prev_chop_coord; //start of cell
INT16 rep_left; //left edge of rep word
uinT8 blanks; //in front of word
uinT8 new_blanks; //blanks in empty cell
inT16 chop_coord; //chop boundary
inT16 prev_chop_coord; //start of cell
inT16 rep_left; //left edge of rep word
ROW *real_row; //output row
OUTLINE_LIST left_outlines; //in current blob
OUTLINE_LIST right_outlines; //for next blob
@ -70,9 +70,9 @@ ROW *fixed_pitch_words( //find lines
//repeated blobs
WERD_IT rep_it = &row->rep_words;
WERD *word; //new word
INT32 xstarts[2]; //row ends
inT32 xstarts[2]; //row ends
double coeffs[3]; //quadratic
INT32 prev_x; //end of prev blob
inT32 prev_x; //end of prev blob
//iterator
BLOBNBOX_IT box_it = row->blob_list ();
//boundaries
@ -145,14 +145,14 @@ ROW *fixed_pitch_words( //find lines
else {
if (rep_left < chop_coord) {
if (rep_left > prev_chop_coord)
new_blanks = (UINT8) floor ((rep_left - prev_chop_coord)
new_blanks = (uinT8) floor ((rep_left - prev_chop_coord)
/ row->fixed_pitch + 0.5);
else
new_blanks = 0;
}
else {
if (chop_coord > prev_chop_coord)
new_blanks = (UINT8) floor ((chop_coord - prev_chop_coord)
new_blanks = (uinT8) floor ((chop_coord - prev_chop_coord)
/ row->fixed_pitch + 0.5);
else
new_blanks = 0;
@ -211,7 +211,7 @@ ROW *fixed_pitch_words( //find lines
coeffs[0] = 0;
coeffs[1] = row->line_m ();
coeffs[2] = row->line_c ();
real_row = new ROW (row, (INT16) row->kern_size, (INT16) row->space_size);
real_row = new ROW (row, (inT16) row->kern_size, (inT16) row->space_size);
word_it.set_to_list (real_row->word_list ());
//put words in row
word_it.add_list_after (&words);
@ -228,17 +228,17 @@ ROW *fixed_pitch_words( //find lines
WERD *add_repeated_word( //move repeated word
WERD_IT *rep_it, //repeated words
INT16 &rep_left, //left edge of word
INT16 &prev_chop_coord, //previous word end
UINT8 &blanks, //no of blanks
inT16 &rep_left, //left edge of word
inT16 &prev_chop_coord, //previous word end
uinT8 &blanks, //no of blanks
float pitch, //char cell size
WERD_IT *word_it //list of words
) {
WERD *word; //word to move
INT16 new_blanks; //extra blanks
inT16 new_blanks; //extra blanks
if (rep_left > prev_chop_coord) {
new_blanks = (UINT8) floor ((rep_left - prev_chop_coord) / pitch + 0.5);
new_blanks = (uinT8) floor ((rep_left - prev_chop_coord) / pitch + 0.5);
blanks += new_blanks;
}
word = rep_it->extract ();
@ -264,7 +264,7 @@ WERD *add_repeated_word( //move repeated word
void split_to_blob( //split the blob
BLOBNBOX *blob, //blob to split
INT16 chop_coord, //place to chop
inT16 chop_coord, //place to chop
float pitch_error, //allowed deviation
OUTLINE_LIST *left_outlines, //left half of chop
C_OUTLINE_LIST *left_coutlines, //for cblobs
@ -307,7 +307,7 @@ void split_to_blob( //split the blob
void fixed_chop_blob( //split the blob
PBLOB *blob, //blob to split
INT16 chop_coord, //place to chop
inT16 chop_coord, //place to chop
float pitch_error, //allowed deviation
OUTLINE_LIST *left_outlines, //left half of chop
OUTLINE_LIST *right_outlines //right half of chop
@ -353,13 +353,13 @@ void fixed_chop_blob( //split the blob
void fixed_split_outline( //chop the outline
OUTLINE *srcline, //source outline
INT16 chop_coord, //place to chop
inT16 chop_coord, //place to chop
float pitch_error, //allowed deviation
OUTLINE_IT *left_it, //left half of chop
OUTLINE_IT *right_it //right half of chop
) {
OUTLINE *child; //child outline
BOX srcbox; //box of outline
TBOX srcbox; //box of outline
OUTLINE_LIST left_ch; //left children
OUTLINE_LIST right_ch; //right children
OUTLINE_FRAG_LIST left_frags; //chopped fragments
@ -405,8 +405,8 @@ void fixed_split_outline( //chop the outline
}
}
}
close_chopped_fragments(&left_frags, &left_ch, left_it);
close_chopped_fragments(&right_frags, &right_ch, right_it);
close_chopped_fragments(&left_frags, &left_ch, left_it);
close_chopped_fragments(&right_frags, &right_ch, right_it);
ASSERT_HOST (left_ch.empty () && right_ch.empty ());
//no children left
delete srcline; //smashed up
@ -432,7 +432,7 @@ void fixed_split_outline( //chop the outline
BOOL8 fixed_chop_outline( //chop the outline
OUTLINE *srcline, //source outline
INT16 chop_coord, //place to chop
inT16 chop_coord, //place to chop
float pitch_error, //allowed deviation
OUTLINE_FRAG_LIST *left_frags, //left half of chop
OUTLINE_FRAG_LIST *right_frags //right half of chop
@ -504,10 +504,10 @@ BOOL8 fixed_chop_outline( //chop the outline
while (tail_it.data ()->pos.x () > chop_coord)
tail_it.backward ();
if (head_it.data () == tail_it.data ())
insert_extra_pt(&tail_it);
insert_chop_pt(&tail_it, chop_coord);
insert_extra_pt(&tail_it);
insert_chop_pt(&tail_it, chop_coord);
if (not_first) {
save_chop_fragment(&head_it, &tail_it, left_frags);
save_chop_fragment(&head_it, &tail_it, left_frags);
}
else {
tail_it.forward ();
@ -545,16 +545,16 @@ BOOL8 fixed_chop_outline( //chop the outline
while (tail_it.data ()->pos.x () < chop_coord)
tail_it.backward ();
if (head_it.data () == tail_it.data ())
insert_extra_pt(&tail_it);
insert_chop_pt(&tail_it, chop_coord);
save_chop_fragment(&head_it, &tail_it, right_frags);
insert_extra_pt(&tail_it);
insert_chop_pt(&tail_it, chop_coord);
save_chop_fragment(&head_it, &tail_it, right_frags);
not_first = TRUE;
}
while (tail_it.data () != startpt);
startpt = head_it.data_relative (-1);
while (tail_it.data () != startpt)
tail_it.forward ();
save_chop_fragment(&head_it, &tail_it, left_frags);
save_chop_fragment(&head_it, &tail_it, left_frags);
return TRUE; //did some chopping
}
@ -578,8 +578,8 @@ void save_chop_fragment( //chop the outline
head = new OUTLINE_FRAG (head_it, tail_it);
tail = new OUTLINE_FRAG (head, tail_y);
head->other_end = tail;
add_frag_to_list(head, frags);
add_frag_to_list(tail, frags);
add_frag_to_list(head, frags);
add_frag_to_list(tail, frags);
head_it->forward ();
tail_it->forward ();
}
@ -646,7 +646,7 @@ void add_frag_to_list( //ordered add
void insert_chop_pt( //make chop
POLYPT_IT *it, //iterator
INT16 chop_coord //required chop pt
inT16 chop_coord //required chop pt
) {
POLYPT *prev_pt; //point befor chop
POLYPT *chop_pt; //new vertex
@ -681,7 +681,7 @@ void insert_chop_pt( //make chop
FCOORD find_chop_coords( //make chop
POLYPT_IT *it, //iterator
INT16 chop_coord //required chop pt
inT16 chop_coord //required chop pt
) {
POLYPT *prev_pt; //point befor chop
FCOORD chop_pos; //coords of chop
@ -766,13 +766,13 @@ void close_chopped_fragments( //chop the outline
}
//find other end
while (frag_it.data () != top_frag->other_end);
join_chopped_fragments(bottom_frag, top_frag);
join_chopped_fragments(bottom_frag, top_frag);
delete top_frag;
delete frag_it.extract (); //remove middle section
frag_it.forward ();
top_frag = frag_it.extract ();
}
join_chopped_fragments(bottom_frag, top_frag);
join_chopped_fragments(bottom_frag, top_frag);
if (bottom_frag->polypts.empty ())
poly_it.set_to_list (&top_frag->polypts);
else
@ -843,7 +843,7 @@ void join_chopped_fragments( //join pieces
void fixed_chop_cblob( //split the blob
C_BLOB *blob, //blob to split
INT16 chop_coord, //place to chop
inT16 chop_coord, //place to chop
float pitch_error, //allowed deviation
C_OUTLINE_LIST *left_outlines, //left half of chop
C_OUTLINE_LIST *right_outlines //right half of chop
@ -889,13 +889,13 @@ void fixed_chop_cblob( //split the blob
void fixed_split_coutline( //chop the outline
C_OUTLINE *srcline, //source outline
INT16 chop_coord, //place to chop
inT16 chop_coord, //place to chop
float pitch_error, //allowed deviation
C_OUTLINE_IT *left_it, //left half of chop
C_OUTLINE_IT *right_it //right half of chop
) {
C_OUTLINE *child; //child outline
BOX srcbox; //box of outline
TBOX srcbox; //box of outline
C_OUTLINE_LIST left_ch; //left children
C_OUTLINE_LIST right_ch; //right children
C_OUTLINE_FRAG_LIST left_frags;//chopped fragments
@ -941,8 +941,8 @@ void fixed_split_coutline( //chop the outline
}
}
}
close_chopped_cfragments(&left_frags, &left_ch, pitch_error, left_it);
close_chopped_cfragments(&right_frags, &right_ch, pitch_error, right_it);
close_chopped_cfragments(&left_frags, &left_ch, pitch_error, left_it);
close_chopped_cfragments(&right_frags, &right_ch, pitch_error, right_it);
ASSERT_HOST (left_ch.empty () && right_ch.empty ());
//no children left
delete srcline; //smashed up
@ -968,23 +968,23 @@ void fixed_split_coutline( //chop the outline
BOOL8 fixed_chop_coutline( //chop the outline
C_OUTLINE *srcline, //source outline
INT16 chop_coord, //place to chop
inT16 chop_coord, //place to chop
float pitch_error, //allowed deviation
C_OUTLINE_FRAG_LIST *left_frags, //left half of chop
C_OUTLINE_FRAG_LIST *right_frags //right half of chop
) {
BOOL8 first_frag; //fragment
BOOL8 anticlock; //direction of loop
INT16 left_edge; //of outline
INT16 startindex; //in first fragment
INT32 length; //of outline
INT16 stepindex; //into outline
INT16 head_index; //start of fragment
inT16 left_edge; //of outline
inT16 startindex; //in first fragment
inT32 length; //of outline
inT16 stepindex; //into outline
inT16 head_index; //start of fragment
ICOORD head_pos; //start of fragment
INT16 tail_index; //end of fragment
inT16 tail_index; //end of fragment
ICOORD tail_pos; //end of fragment
ICOORD pos; //current point
INT16 first_index = 0; //first tail
inT16 first_index = 0; //first tail
ICOORD first_pos; //first tail
length = srcline->pathlength ();
@ -1091,18 +1091,18 @@ BOOL8 fixed_chop_coutline( //chop the outline
* chop_coord from left to right.
**********************************************************************/
INT16 next_anti_left_seg( //chop the outline
inT16 next_anti_left_seg( //chop the outline
C_OUTLINE *srcline, //source outline
INT16 tail_index, //of tailpos
INT16 startindex, //end of search
INT32 length, //of outline
INT16 chop_coord, //place to chop
inT16 tail_index, //of tailpos
inT16 startindex, //end of search
inT32 length, //of outline
inT16 chop_coord, //place to chop
float pitch_error, //allowed deviation
ICOORD *tail_pos //current position
) {
BOOL8 test_valid; //test pt valid
INT16 chop_starty; //test chop pt
INT16 test_index; //possible chop pt
inT16 chop_starty; //test chop pt
inT16 test_index; //possible chop pt
ICOORD test_pos; //possible chop pt
ICOORD prev_step; //in x to tail pos
@ -1152,18 +1152,18 @@ INT16 next_anti_left_seg( //chop the outline
* chop_coord from right to left.
**********************************************************************/
INT16 next_anti_right_seg( //chop the outline
inT16 next_anti_right_seg( //chop the outline
C_OUTLINE *srcline, //source outline
INT16 tail_index, //of tailpos
INT16 startindex, //end of search
INT32 length, //of outline
INT16 chop_coord, //place to chop
inT16 tail_index, //of tailpos
inT16 startindex, //end of search
inT32 length, //of outline
inT16 chop_coord, //place to chop
float pitch_error, //allowed deviation
ICOORD *tail_pos //current position
) {
BOOL8 test_valid; //test pt valid
INT16 chop_starty; //test chop pt
INT16 test_index; //possible chop pt
inT16 chop_starty; //test chop pt
inT16 test_index; //possible chop pt
ICOORD test_pos; //possible chop pt
ICOORD prev_step; //in x to tail pos
@ -1214,18 +1214,18 @@ INT16 next_anti_right_seg( //chop the outline
* chop_coord from left to right.
**********************************************************************/
INT16 next_clock_left_seg( //chop the outline
inT16 next_clock_left_seg( //chop the outline
C_OUTLINE *srcline, //source outline
INT16 tail_index, //of tailpos
INT16 startindex, //end of search
INT32 length, //of outline
INT16 chop_coord, //place to chop
inT16 tail_index, //of tailpos
inT16 startindex, //end of search
inT32 length, //of outline
inT16 chop_coord, //place to chop
float pitch_error, //allowed deviation
ICOORD *tail_pos //current position
) {
BOOL8 test_valid; //test pt valid
INT16 chop_starty; //test chop pt
INT16 test_index; //possible chop pt
inT16 chop_starty; //test chop pt
inT16 test_index; //possible chop pt
ICOORD test_pos; //possible chop pt
ICOORD prev_step; //in x to tail pos
@ -1275,18 +1275,18 @@ INT16 next_clock_left_seg( //chop the outline
* chop_coord from right to left.
**********************************************************************/
INT16 next_clock_right_seg( //chop the outline
inT16 next_clock_right_seg( //chop the outline
C_OUTLINE *srcline, //source outline
INT16 tail_index, //of tailpos
INT16 startindex, //end of search
INT32 length, //of outline
INT16 chop_coord, //place to chop
inT16 tail_index, //of tailpos
inT16 startindex, //end of search
inT32 length, //of outline
inT16 chop_coord, //place to chop
float pitch_error, //allowed deviation
ICOORD *tail_pos //current position
) {
BOOL8 test_valid; //test pt valid
INT16 chop_starty; //test chop pt
INT16 test_index; //possible chop pt
inT16 chop_starty; //test chop pt
inT16 test_index; //possible chop pt
ICOORD test_pos; //possible chop pt
ICOORD prev_step; //in x to tail pos
@ -1337,18 +1337,18 @@ INT16 next_clock_right_seg( //chop the outline
**********************************************************************/
void save_chop_cfragment( //chop the outline
INT16 head_index, //head of fragment
inT16 head_index, //head of fragment
ICOORD head_pos, //head of fragment
INT16 tail_index, //tail of fragment
inT16 tail_index, //tail of fragment
ICOORD tail_pos, //tail of fragment
C_OUTLINE *srcline, //source of edgesteps
C_OUTLINE_FRAG_LIST *frags //fragment list
) {
INT16 jump; //gap across end
INT16 stepcount; //total steps
inT16 jump; //gap across end
inT16 stepcount; //total steps
C_OUTLINE_FRAG *head; //head of fragment
C_OUTLINE_FRAG *tail; //tail of fragment
INT16 tail_y; //ycoord of tail
inT16 tail_y; //ycoord of tail
ASSERT_HOST (tail_pos.x () == head_pos.x ());
ASSERT_HOST (tail_index != head_index);
@ -1365,8 +1365,8 @@ void save_chop_cfragment( //chop the outline
head_index, tail_index);
tail = new C_OUTLINE_FRAG (head, tail_y);
head->other_end = tail;
add_frag_to_list(head, frags);
add_frag_to_list(tail, frags);
add_frag_to_list(head, frags);
add_frag_to_list(tail, frags);
}
@ -1380,8 +1380,8 @@ C_OUTLINE_FRAG::C_OUTLINE_FRAG( //record fragment
ICOORD start_pt, //start coord
ICOORD end_pt, //end coord
C_OUTLINE *outline, //source of steps
INT16 start_index,
INT16 end_index) {
inT16 start_index,
inT16 end_index) {
start = start_pt;
end = end_pt;
ycoord = start_pt.y ();
@ -1404,13 +1404,13 @@ C_OUTLINE_FRAG::C_OUTLINE_FRAG( //record fragment
steps[i - start_index] = outline->step_dir(i - len);
}
other_end = NULL;
delete close();
delete close();
}
C_OUTLINE_FRAG::C_OUTLINE_FRAG( //record fragment
C_OUTLINE_FRAG *head, //other end
INT16 tail_y) {
inT16 tail_y) {
ycoord = tail_y;
other_end = head;
start = head->start;
@ -1560,8 +1560,8 @@ void join_segments( //join pieces
C_OUTLINE_FRAG *top //top of cut
) {
DIR128 *steps; //new steps
INT32 stepcount; //no of steps
INT16 fake_count; //fake steps
inT32 stepcount; //no of steps
inT16 fake_count; //fake steps
DIR128 fake_step; //step entry
ASSERT_HOST (bottom->end.x () == top->start.x ());
@ -1595,8 +1595,8 @@ void join_segments( //join pieces
C_OUTLINE *C_OUTLINE_FRAG::close() { //join pieces
DIR128 *new_steps; //new steps
INT32 new_stepcount; //no of steps
INT16 fake_count; //fake steps
inT32 new_stepcount; //no of steps
inT16 fake_count; //fake steps
DIR128 fake_step; //step entry
ASSERT_HOST (start.x () == end.x ());
@ -1610,7 +1610,7 @@ C_OUTLINE *C_OUTLINE_FRAG::close() { //join pieces
new_stepcount = stepcount + fake_count;
new_steps = new DIR128[new_stepcount];
memmove(new_steps, steps, stepcount);
memmove(new_steps, steps, stepcount);
memset (new_steps + stepcount, fake_step.get_dir(), fake_count);
C_OUTLINE* result = new C_OUTLINE (start, new_steps, new_stepcount);
delete [] new_steps;
@ -1629,7 +1629,7 @@ C_OUTLINE_FRAG & C_OUTLINE_FRAG::operator= (
const C_OUTLINE_FRAG & src //fragment to copy
) {
if (steps != NULL)
delete [] steps;
delete [] steps;
stepcount = src.stepcount;
steps = new DIR128[stepcount];

View File

@ -28,12 +28,12 @@
class OUTLINE_FRAG:public ELIST_LINK
{
public:
OUTLINE_FRAG() {
OUTLINE_FRAG() {
} //empty constructor
//head of fragment
OUTLINE_FRAG(POLYPT_IT *head_it, POLYPT_IT *tail_it); //tail of fragment
//other end
OUTLINE_FRAG(OUTLINE_FRAG *head, float tail_y);
OUTLINE_FRAG(OUTLINE_FRAG *head, float tail_y);
POLYPT_LIST polypts; //only if a head
OUTLINE_FRAG *other_end; //head if a tail
@ -51,16 +51,16 @@ class C_OUTLINE_FRAG:public ELIST_LINK
}
~C_OUTLINE_FRAG () {
if (steps != NULL)
delete [] steps;
delete [] steps;
}
//start coord
C_OUTLINE_FRAG(ICOORD start_pt,
ICOORD end_pt, //end coord
C_OUTLINE *outline, //source of steps
INT16 start_index,
INT16 end_index);
inT16 start_index,
inT16 end_index);
//other end
C_OUTLINE_FRAG(C_OUTLINE_FRAG *head, INT16 tail_y);
C_OUTLINE_FRAG(C_OUTLINE_FRAG *head, inT16 tail_y);
C_OUTLINE *close(); //copy to outline
C_OUTLINE_FRAG & operator= ( //assign
const C_OUTLINE_FRAG & src);
@ -68,9 +68,9 @@ class C_OUTLINE_FRAG:public ELIST_LINK
ICOORD start; //start coord
ICOORD end; //end coord
DIR128 *steps; //step array
INT32 stepcount; //no of steps
inT32 stepcount; //no of steps
C_OUTLINE_FRAG *other_end; //head if a tail
INT16 ycoord; //coord of cut pt
inT16 ycoord; //coord of cut pt
private:
};
@ -88,15 +88,15 @@ ROW *fixed_pitch_words( //find lines
);
WERD *add_repeated_word( //move repeated word
WERD_IT *rep_it, //repeated words
INT16 &rep_left, //left edge of word
INT16 &prev_chop_coord, //previous word end
UINT8 &blanks, //no of blanks
inT16 &rep_left, //left edge of word
inT16 &prev_chop_coord, //previous word end
uinT8 &blanks, //no of blanks
float pitch, //char cell size
WERD_IT *word_it //list of words
);
void split_to_blob( //split the blob
BLOBNBOX *blob, //blob to split
INT16 chop_coord, //place to chop
inT16 chop_coord, //place to chop
float pitch_error, //allowed deviation
OUTLINE_LIST *left_outlines, //left half of chop
C_OUTLINE_LIST *left_coutlines, //for cblobs
@ -104,21 +104,21 @@ void split_to_blob( //split the blob
C_OUTLINE_LIST *right_coutlines);
void fixed_chop_blob( //split the blob
PBLOB *blob, //blob to split
INT16 chop_coord, //place to chop
inT16 chop_coord, //place to chop
float pitch_error, //allowed deviation
OUTLINE_LIST *left_outlines, //left half of chop
OUTLINE_LIST *right_outlines //right half of chop
);
void fixed_split_outline( //chop the outline
OUTLINE *srcline, //source outline
INT16 chop_coord, //place to chop
inT16 chop_coord, //place to chop
float pitch_error, //allowed deviation
OUTLINE_IT *left_it, //left half of chop
OUTLINE_IT *right_it //right half of chop
);
BOOL8 fixed_chop_outline( //chop the outline
OUTLINE *srcline, //source outline
INT16 chop_coord, //place to chop
inT16 chop_coord, //place to chop
float pitch_error, //allowed deviation
OUTLINE_FRAG_LIST *left_frags, //left half of chop
OUTLINE_FRAG_LIST *right_frags //right half of chop
@ -134,11 +134,11 @@ void add_frag_to_list( //ordered add
);
void insert_chop_pt( //make chop
POLYPT_IT *it, //iterator
INT16 chop_coord //required chop pt
inT16 chop_coord //required chop pt
);
FCOORD find_chop_coords( //make chop
POLYPT_IT *it, //iterator
INT16 chop_coord //required chop pt
inT16 chop_coord //required chop pt
);
void insert_extra_pt( //make extra
POLYPT_IT *it //iterator
@ -154,65 +154,65 @@ void join_chopped_fragments( //join pieces
);
void fixed_chop_cblob( //split the blob
C_BLOB *blob, //blob to split
INT16 chop_coord, //place to chop
inT16 chop_coord, //place to chop
float pitch_error, //allowed deviation
C_OUTLINE_LIST *left_outlines, //left half of chop
C_OUTLINE_LIST *right_outlines //right half of chop
);
void fixed_split_coutline( //chop the outline
C_OUTLINE *srcline, //source outline
INT16 chop_coord, //place to chop
inT16 chop_coord, //place to chop
float pitch_error, //allowed deviation
C_OUTLINE_IT *left_it, //left half of chop
C_OUTLINE_IT *right_it //right half of chop
);
BOOL8 fixed_chop_coutline( //chop the outline
C_OUTLINE *srcline, //source outline
INT16 chop_coord, //place to chop
inT16 chop_coord, //place to chop
float pitch_error, //allowed deviation
C_OUTLINE_FRAG_LIST *left_frags, //left half of chop
C_OUTLINE_FRAG_LIST *right_frags //right half of chop
);
INT16 next_anti_left_seg( //chop the outline
inT16 next_anti_left_seg( //chop the outline
C_OUTLINE *srcline, //source outline
INT16 tail_index, //of tailpos
INT16 startindex, //end of search
INT32 length, //of outline
INT16 chop_coord, //place to chop
inT16 tail_index, //of tailpos
inT16 startindex, //end of search
inT32 length, //of outline
inT16 chop_coord, //place to chop
float pitch_error, //allowed deviation
ICOORD *tail_pos //current position
);
INT16 next_anti_right_seg( //chop the outline
inT16 next_anti_right_seg( //chop the outline
C_OUTLINE *srcline, //source outline
INT16 tail_index, //of tailpos
INT16 startindex, //end of search
INT32 length, //of outline
INT16 chop_coord, //place to chop
inT16 tail_index, //of tailpos
inT16 startindex, //end of search
inT32 length, //of outline
inT16 chop_coord, //place to chop
float pitch_error, //allowed deviation
ICOORD *tail_pos //current position
);
INT16 next_clock_left_seg( //chop the outline
inT16 next_clock_left_seg( //chop the outline
C_OUTLINE *srcline, //source outline
INT16 tail_index, //of tailpos
INT16 startindex, //end of search
INT32 length, //of outline
INT16 chop_coord, //place to chop
inT16 tail_index, //of tailpos
inT16 startindex, //end of search
inT32 length, //of outline
inT16 chop_coord, //place to chop
float pitch_error, //allowed deviation
ICOORD *tail_pos //current position
);
INT16 next_clock_right_seg( //chop the outline
inT16 next_clock_right_seg( //chop the outline
C_OUTLINE *srcline, //source outline
INT16 tail_index, //of tailpos
INT16 startindex, //end of search
INT32 length, //of outline
INT16 chop_coord, //place to chop
inT16 tail_index, //of tailpos
inT16 startindex, //end of search
inT32 length, //of outline
inT16 chop_coord, //place to chop
float pitch_error, //allowed deviation
ICOORD *tail_pos //current position
);
void save_chop_cfragment( //chop the outline
INT16 head_index, //head of fragment
inT16 head_index, //head of fragment
ICOORD head_pos, //head of fragment
INT16 tail_index, //tail of fragment
inT16 tail_index, //tail of fragment
ICOORD tail_pos, //tail of fragment
C_OUTLINE *srcline, //source of edgesteps
C_OUTLINE_FRAG_LIST *frags //fragment list

View File

@ -30,15 +30,15 @@ GAPMAP::GAPMAP( //Constructor
TO_ROW_IT row_it; //row iterator
TO_ROW *row; //current row
BLOBNBOX_IT blob_it; //iterator
BOX blob_box;
BOX prev_blob_box;
INT16 gap_width;
INT16 start_of_row;
INT16 end_of_row;
TBOX blob_box;
TBOX prev_blob_box;
inT16 gap_width;
inT16 start_of_row;
inT16 end_of_row;
STATS xht_stats (0, 128);
INT16 min_quantum;
INT16 max_quantum;
INT16 i;
inT16 min_quantum;
inT16 max_quantum;
inT16 i;
row_it.set_to_list (block->get_rows ());
/*
@ -53,7 +53,7 @@ GAPMAP::GAPMAP( //Constructor
row = row_it.data ();
if (!row->blob_list ()->empty ()) {
total_rows++;
xht_stats.add ((INT16) floor (row->xheight + 0.5), 1);
xht_stats.add ((inT16) floor (row->xheight + 0.5), 1);
blob_it.set_to_list (row->blob_list ());
start_of_row = blob_it.data ()->bounding_box ().left ();
end_of_row = blob_it.data_relative (-1)->bounding_box ().right ();
@ -68,9 +68,9 @@ GAPMAP::GAPMAP( //Constructor
min_left = max_right = 0;
return;
}
bucket_size = (INT16) floor (xht_stats.median () + 0.5) / 2;
bucket_size = (inT16) floor (xht_stats.median () + 0.5) / 2;
map_max = (max_right - min_left) / bucket_size;
map = (INT16 *) alloc_mem ((map_max + 1) * sizeof (INT16));
map = (inT16 *) alloc_mem ((map_max + 1) * sizeof (inT16));
for (i = 0; i <= map_max; i++)
map[i] = 0;
@ -146,12 +146,12 @@ GAPMAP::GAPMAP( //Constructor
*************************************************************************/
BOOL8 GAPMAP::table_gap( //Is gap a table?
INT16 left, //From here
INT16 right //To here
inT16 left, //From here
inT16 right //To here
) {
INT16 min_quantum;
INT16 max_quantum;
INT16 i;
inT16 min_quantum;
inT16 max_quantum;
inT16 i;
BOOL8 tab_found = FALSE;
if (!any_tabs)

View File

@ -12,20 +12,20 @@ class GAPMAP
~GAPMAP () { //destructor
if (map != NULL)
free_mem(map);
free_mem(map);
}
BOOL8 table_gap( //Is gap a table?
INT16 left, //From here
INT16 right); //To here
inT16 left, //From here
inT16 right); //To here
private:
INT16 total_rows; //in block
INT16 min_left; //Left extreme
INT16 max_right; //Right extreme
INT16 bucket_size; // half an x ht
INT16 *map; //empty counts
INT16 map_max; //map[0..max_map] defind
inT16 total_rows; //in block
inT16 min_left; //Left extreme
inT16 max_right; //Right extreme
inT16 bucket_size; // half an x ht
inT16 *map; //empty counts
inT16 map_max; //map[0..max_map] defind
BOOL8 any_tabs;
};

View File

@ -224,7 +224,7 @@ void fit_lms_line( //sort function
TO_ROW *row //row to fit
) {
float m, c; //fitted line
BOX box; //blob box
TBOX box; //blob box
LMS lms (row->blob_list ()->length ());
//blobs
BLOBNBOX_IT blob_it = row->blob_list ();
@ -250,12 +250,12 @@ void compute_page_skew( //get average gradient
float &page_m, //average gradient
float &page_err //average error
) {
INT32 row_count; //total rows
INT32 blob_count; //total_blobs
INT32 row_err; //integer error
inT32 row_count; //total rows
inT32 blob_count; //total_blobs
inT32 row_err; //integer error
float *gradients; //of rows
float *errors; //of rows
INT32 row_index; //of total
inT32 row_index; //of total
TO_ROW *row; //current row
TO_BLOCK_IT block_it = blocks; //iterator
TO_ROW_IT row_it;
@ -288,7 +288,7 @@ void compute_page_skew( //get average gradient
for (row_it.mark_cycle_pt (); !row_it.cycled_list (); row_it.forward ()) {
row = row_it.data ();
blob_count = row->blob_list ()->length ();
row_err = (INT32) ceil (row->line_error ());
row_err = (inT32) ceil (row->line_error ());
if (row_err <= 0)
row_err = 1;
if (textord_biased_skewcalc) {
@ -322,10 +322,10 @@ void compute_page_skew( //get average gradient
}
}
row_count = row_index;
row_index = choose_nth_item ((INT32) (row_count * textord_skew_ile),
row_index = choose_nth_item ((inT32) (row_count * textord_skew_ile),
gradients, row_count);
page_m = gradients[row_index];
row_index = choose_nth_item ((INT32) (row_count * textord_skew_ile),
row_index = choose_nth_item ((inT32) (row_count * textord_skew_ile),
errors, row_count);
page_err = errors[row_index];
free_mem(gradients);
@ -338,8 +338,8 @@ const int kMinSize = 8; // Min pixels to be xheight.
// Return true if the dot looks like it is part of the i.
// Doesn't work for any other diacritical.
static bool dot_of_i(BLOBNBOX* dot, BLOBNBOX* i, TO_ROW* row) {
const BOX& ibox = i->bounding_box();
const BOX& dotbox = dot->bounding_box();
const TBOX& ibox = i->bounding_box();
const TBOX& dotbox = dot->bounding_box();
// Must overlap horizontally by enough and be high enough.
int overlap = MIN(dotbox.right(), ibox.right()) -
@ -444,7 +444,7 @@ static void vigorous_noise_removal(TO_BLOCK* block) {
BLOBNBOX* prev = NULL;
for (b_it.mark_cycle_pt(); !b_it.cycled_list(); b_it.forward()) {
BLOBNBOX* blob = b_it.data();
const BOX& box = blob->bounding_box();
const TBOX& box = blob->bounding_box();
if (box.height() < kNoiseSize * xheight) {
// Small so delete unless it looks like an i dot.
if (prev != NULL) {
@ -480,7 +480,7 @@ void cleanup_rows( //find lines
TO_BLOCK *block, //block to do
float gradient, //gradient to fit
FCOORD rotation, //for drawing
INT32 block_edge, //edge of block
inT32 block_edge, //edge of block
BOOL8 testing_on //correct orientation
) {
//iterators
@ -578,19 +578,19 @@ void delete_non_dropout_rows( //find lines
TO_BLOCK *block, //block to do
float gradient, //global skew
FCOORD rotation, //deskew vector
INT32 block_edge, //left edge
inT32 block_edge, //left edge
BOOL8 testing_on //correct orientation
) {
BOX block_box; //deskewed block
INT32 *deltas; //change in occupation
INT32 *occupation; //of pixel coords
INT32 max_y; //in block
INT32 min_y;
INT32 line_index; //of scan line
INT32 line_count; //no of scan lines
INT32 distance; //to drop-out
INT32 xleft; //of block
INT32 ybottom; //of block
TBOX block_box; //deskewed block
inT32 *deltas; //change in occupation
inT32 *occupation; //of pixel coords
inT32 max_y; //in block
inT32 min_y;
inT32 line_index; //of scan line
inT32 line_count; //no of scan lines
inT32 distance; //to drop-out
inT32 xleft; //of block
inT32 ybottom; //of block
TO_ROW *row; //current row
TO_ROW_IT row_it = block->get_rows ();
BLOBNBOX_IT blob_it = &block->blobs;
@ -603,7 +603,7 @@ void delete_non_dropout_rows( //find lines
min_y = block_box.bottom () - 1;
max_y = block_box.top () + 1;
for (row_it.mark_cycle_pt (); !row_it.cycled_list (); row_it.forward ()) {
line_index = (INT32) floor (row_it.data ()->intercept ());
line_index = (inT32) floor (row_it.data ()->intercept ());
if (line_index <= min_y)
min_y = line_index - 1;
if (line_index >= max_y)
@ -612,17 +612,17 @@ void delete_non_dropout_rows( //find lines
line_count = max_y - min_y + 1;
if (line_count <= 0)
return; //empty block
deltas = (INT32 *) alloc_mem (line_count * sizeof (INT32));
occupation = (INT32 *) alloc_mem (line_count * sizeof (INT32));
deltas = (inT32 *) alloc_mem (line_count * sizeof (inT32));
occupation = (inT32 *) alloc_mem (line_count * sizeof (inT32));
if (deltas == NULL || occupation == NULL)
MEMORY_OUT.error ("compute_line_spacing", ABORT, NULL);
compute_line_occupation(block, gradient, min_y, max_y, occupation, deltas);
compute_occupation_threshold ((INT32)
compute_occupation_threshold ((inT32)
ceil (block->line_spacing *
(textord_merge_desc +
textord_merge_asc)),
(INT32) ceil (block->line_spacing *
(inT32) ceil (block->line_spacing *
(textord_merge_x +
textord_merge_asc)),
max_y - min_y + 1, occupation, deltas);
@ -634,7 +634,7 @@ void delete_non_dropout_rows( //find lines
compute_dropout_distances(occupation, deltas, line_count);
for (row_it.mark_cycle_pt (); !row_it.cycled_list (); row_it.forward ()) {
row = row_it.data ();
line_index = (INT32) floor (row->intercept ());
line_index = (inT32) floor (row->intercept ());
distance = deltas[line_index - min_y];
if (find_best_dropout_row (row, distance, block->line_spacing / 2,
line_index, &row_it, testing_on)) {
@ -665,16 +665,16 @@ void delete_non_dropout_rows( //find lines
BOOL8 find_best_dropout_row( //find neighbours
TO_ROW *row, //row to test
INT32 distance, //dropout dist
inT32 distance, //dropout dist
float dist_limit, //threshold distance
INT32 line_index, //index of row
inT32 line_index, //index of row
TO_ROW_IT *row_it, //current position
BOOL8 testing_on //correct orientation
) {
INT32 next_index; //of neigbouring row
INT32 row_offset; //from current row
INT32 abs_dist; //absolute distance
INT8 row_inc; //increment to row_index
inT32 next_index; //of neigbouring row
inT32 row_offset; //from current row
inT32 abs_dist; //absolute distance
inT8 row_inc; //increment to row_index
TO_ROW *next_row; //nextious row
if (testing_on)
@ -699,7 +699,7 @@ BOOL8 find_best_dropout_row( //find neighbours
row_offset = row_inc;
do {
next_row = row_it->data_relative (row_offset);
next_index = (INT32) floor (next_row->intercept ());
next_index = (inT32) floor (next_row->intercept ());
if ((distance < 0
&& next_index < line_index
&& next_index > line_index + distance + distance)
@ -744,12 +744,12 @@ BOOL8 find_best_dropout_row( //find neighbours
* if they were deskewed without actually doing it.
**********************************************************************/
BOX deskew_block_coords( //block box
TBOX deskew_block_coords( //block box
TO_BLOCK *block, //block to do
float gradient //global skew
) {
BOX result; //block bounds
BOX blob_box; //of block
TBOX result; //block bounds
TBOX blob_box; //of block
FCOORD rotation; //deskew vector
float length; //of gradient vector
TO_ROW_IT row_it = block->get_rows ();
@ -784,22 +784,22 @@ BOX deskew_block_coords( //block box
void compute_line_occupation( //project blobs
TO_BLOCK *block, //block to do
float gradient, //global skew
INT32 min_y, //min coord in block
INT32 max_y, //in block
INT32 *occupation, //output projection
INT32 *deltas //derivative
inT32 min_y, //min coord in block
inT32 max_y, //in block
inT32 *occupation, //output projection
inT32 *deltas //derivative
) {
INT32 line_count; //maxy-miny+1
INT32 line_index; //of scan line
inT32 line_count; //maxy-miny+1
inT32 line_index; //of scan line
int index; //array index for daft compilers
float top, bottom; //coords of blob
INT32 width; //of blob
inT32 width; //of blob
TO_ROW *row; //current row
TO_ROW_IT row_it = block->get_rows ();
BLOBNBOX *blob; //current blob
BLOBNBOX_IT blob_it; //iterator
float length; //of skew vector
BOX blob_box; //bounding box
TBOX blob_box; //bounding box
FCOORD rotation; //inverse of skew
line_count = max_y - min_y + 1;
@ -818,21 +818,21 @@ void compute_line_occupation( //project blobs
top = blob_box.top ();
bottom = blob_box.bottom ();
width =
(INT32) floor ((FLOAT32) (blob_box.right () - blob_box.left ()));
if ((INT32) floor (bottom) < min_y
|| (INT32) floor (bottom) - min_y >= line_count)
(inT32) floor ((FLOAT32) (blob_box.right () - blob_box.left ()));
if ((inT32) floor (bottom) < min_y
|| (inT32) floor (bottom) - min_y >= line_count)
fprintf (stderr,
"Bad y coord of bottom, " INT32FORMAT "(" INT32FORMAT ","
INT32FORMAT ")\n", (INT32) floor (bottom), min_y, max_y);
INT32FORMAT ")\n", (inT32) floor (bottom), min_y, max_y);
//count transitions
index = (INT32) floor (bottom) - min_y;
index = (inT32) floor (bottom) - min_y;
deltas[index] += width;
if ((INT32) floor (top) < min_y
|| (INT32) floor (top) - min_y >= line_count)
if ((inT32) floor (top) < min_y
|| (inT32) floor (top) - min_y >= line_count)
fprintf (stderr,
"Bad y coord of top, " INT32FORMAT "(" INT32FORMAT ","
INT32FORMAT ")\n", (INT32) floor (top), min_y, max_y);
index = (INT32) floor (top) - min_y;
INT32FORMAT ")\n", (inT32) floor (top), min_y, max_y);
index = (inT32) floor (top) - min_y;
deltas[index] -= width;
}
}
@ -849,23 +849,23 @@ void compute_line_occupation( //project blobs
**********************************************************************/
void compute_occupation_threshold( //project blobs
INT32 low_window, //below result point
INT32 high_window, //above result point
INT32 line_count, //array sizes
INT32 *occupation, //input projection
INT32 *thresholds //output thresholds
inT32 low_window, //below result point
inT32 high_window, //above result point
inT32 line_count, //array sizes
inT32 *occupation, //input projection
inT32 *thresholds //output thresholds
) {
INT32 line_index; //of thresholds line
INT32 low_index; //in occupation
INT32 high_index; //in occupation
INT32 sum; //current average
INT32 divisor; //to get thresholds
INT32 min_index; //of min occ
INT32 min_occ; //min in locality
INT32 test_index; //for finding min
inT32 line_index; //of thresholds line
inT32 low_index; //in occupation
inT32 high_index; //in occupation
inT32 sum; //current average
inT32 divisor; //to get thresholds
inT32 min_index; //of min occ
inT32 min_occ; //min in locality
inT32 test_index; //for finding min
divisor =
(INT32) ceil ((low_window + high_window) / textord_occupancy_threshold);
(inT32) ceil ((low_window + high_window) / textord_occupancy_threshold);
if (low_window + high_window < line_count) {
for (sum = 0, high_index = 0; high_index < low_window; high_index++)
sum += occupation[high_index];
@ -931,15 +931,15 @@ void compute_occupation_threshold( //project blobs
**********************************************************************/
void compute_dropout_distances( //project blobs
INT32 *occupation, //input projection
INT32 *thresholds, //output thresholds
INT32 line_count //array sizes
inT32 *occupation, //input projection
inT32 *thresholds, //output thresholds
inT32 line_count //array sizes
) {
INT32 line_index; //of thresholds line
INT32 distance; //from prev dropout
INT32 next_dist; //to next dropout
INT32 back_index; //for back filling
INT32 prev_threshold; //before overwrite
inT32 line_index; //of thresholds line
inT32 distance; //from prev dropout
inT32 next_dist; //to next dropout
inT32 back_index; //for back filling
inT32 prev_threshold; //before overwrite
distance = -line_count;
line_index = 0;
@ -983,7 +983,7 @@ void expand_rows( //find lines
TO_BLOCK *block, //block to do
float gradient, //gradient to fit
FCOORD rotation, //for drawing
INT32 block_edge, //edge of block
inT32 block_edge, //edge of block
BOOL8 testing_on //correct orientation
) {
BOOL8 swallowed_row; //eaten a neighbour
@ -1174,13 +1174,13 @@ void compute_row_stats( //find lines
TO_BLOCK *block, //block to do
BOOL8 testing_on //correct orientation
) {
INT32 row_index; //of median
inT32 row_index; //of median
TO_ROW *row; //current row
TO_ROW *prev_row; //previous row
float iqr; //inter quartile range
TO_ROW_IT row_it = block->get_rows ();
//number of rows
INT16 rowcount = row_it.length ();
inT16 rowcount = row_it.length ();
TO_ROW **rows; //for choose nth
rows = (TO_ROW **) alloc_mem (rowcount * sizeof (TO_ROW *));
@ -1270,8 +1270,8 @@ void compute_block_xheight( //find lines
int xh_count, desc_count; //no of samples
float block_median; //median blob size
int asc_count, cap_count;
INT32 min_size, max_size; //limits on xheight
INT32 evidence; //no of samples on row
inT32 min_size, max_size; //limits on xheight
inT32 evidence; //no of samples on row
float xh_sum, desc_sum; //for averages
float asc_sum, cap_sum;
TO_ROW_IT row_it = block->get_rows ();
@ -1285,8 +1285,8 @@ void compute_block_xheight( //find lines
block_median = block->line_size;
// tprintf("Block median=%g, linesize=%g\n",
// block_median,block->line_size);
max_size = (INT32) ceil (block_median);
min_size = (INT32) floor (block_median * textord_minxh);
max_size = (inT32) ceil (block_median);
min_size = (inT32) floor (block_median * textord_minxh);
row_heights.set_range (min_size, max_size + 1);
xh_count = desc_count = asc_count = cap_count = 0;
xh_sum = desc_sum = asc_sum = cap_sum = 0.0f;
@ -1294,7 +1294,7 @@ void compute_block_xheight( //find lines
row = row_it.data ();
evidence = compute_row_xheight (row, min_size, max_size, gradient);
if (row->xheight > 0 && row->ascrise > 0) {
row_heights.add ((INT32) row->xheight, evidence);
row_heights.add ((inT32) row->xheight, evidence);
xh_count += evidence;
asc_sum += row->ascrise;
asc_count++;
@ -1360,8 +1360,8 @@ float median_block_xheight( //find lines
BLOBNBOX_IT blob_it;
BLOBNBOX *blob; //current blob
float *heights; //for choose nth
INT32 blob_count; //blobs in block
INT32 blob_index; //current blob
inT32 blob_count; //blobs in block
inT32 blob_index; //current blob
blob_count = 0;
for (row_it.mark_cycle_pt (); !row_it.cycled_list (); row_it.forward ())
@ -1405,26 +1405,26 @@ float median_block_xheight( //find lines
* Compute the ascender rise and descender drop at the same time.
**********************************************************************/
INT32 compute_row_xheight( //find lines
inT32 compute_row_xheight( //find lines
TO_ROW *row, //row to do
INT32 min_height, //min xheight
INT32 max_height, //max xheight
inT32 min_height, //min xheight
inT32 max_height, //max xheight
float gradient //global skew
) {
BOOL8 in_best_pile; //control of mode size
INT32 prev_size; //previous size
inT32 prev_size; //previous size
float xcentre; //centre of blob
float height; //height of blob
BLOBNBOX_IT blob_it = row->blob_list ();
BLOBNBOX *blob; //current blob
INT32 blob_count; //blobs in block
INT32 x; //xheight index
INT32 asc; //ascender index
INT32 blob_index; //current blob
INT32 mode_count; //no of modes
INT32 best_count; //count of best x so far
inT32 blob_count; //blobs in block
inT32 x; //xheight index
inT32 asc; //ascender index
inT32 blob_index; //current blob
inT32 mode_count; //no of modes
inT32 best_count; //count of best x so far
float ratio; //size ratio
INT32 modes[MAX_HEIGHT_MODES]; //biggest piles
inT32 modes[MAX_HEIGHT_MODES]; //biggest piles
STATS heights (min_height, max_height + 1);
for (blob_it.mark_cycle_pt (); !blob_it.cycled_list (); blob_it.forward ()) {
@ -1440,7 +1440,7 @@ INT32 compute_row_xheight( //find lines
height -= gradient * xcentre + row->parallel_c ();
if (height >= min_height && height <= max_height
&& (!textord_xheight_tweak || height > textord_min_xheight))
heights.add ((INT32) floor (height + 0.5), 1);
heights.add ((inT32) floor (height + 0.5), 1);
}
}
blob_index = heights.mode (); //find mode
@ -1509,18 +1509,18 @@ INT32 compute_row_xheight( //find lines
* Estimate the descdrop of this row.
**********************************************************************/
INT32 compute_row_descdrop( //find lines
inT32 compute_row_descdrop( //find lines
TO_ROW *row, //row to do
float gradient //global skew
) {
INT32 min_height = (INT32) floor (row->xheight * textord_descx_ratio_min);
INT32 max_height = (INT32) floor (row->xheight * textord_descx_ratio_max);
inT32 min_height = (inT32) floor (row->xheight * textord_descx_ratio_min);
inT32 max_height = (inT32) floor (row->xheight * textord_descx_ratio_max);
float xcentre; //centre of blob
float height; //height of blob
BLOBNBOX_IT blob_it = row->blob_list ();
BLOBNBOX *blob; //current blob
INT32 blob_count; //blobs in block
INT32 blob_index; //current blob
inT32 blob_count; //blobs in block
inT32 blob_index; //current blob
STATS heights (min_height, max_height + 1);
for (blob_it.mark_cycle_pt (); !blob_it.cycled_list (); blob_it.forward ()) {
@ -1533,7 +1533,7 @@ INT32 compute_row_descdrop( //find lines
gradient * xcentre + row->parallel_c () -
blob->bounding_box ().bottom ();
if (height >= min_height && height <= max_height)
heights.add ((INT32) floor (height + 0.5), 1);
heights.add ((inT32) floor (height + 0.5), 1);
}
}
blob_index = heights.mode (); //find mode
@ -1550,19 +1550,19 @@ INT32 compute_row_descdrop( //find lines
* indices in the output in the order in which they occurred.
**********************************************************************/
INT32 compute_height_modes( //find lines
inT32 compute_height_modes( //find lines
STATS *heights, //stats to search
INT32 min_height, //bottom of range
INT32 max_height, //top of range
INT32 *modes, //output array
INT32 maxmodes //size of modes
inT32 min_height, //bottom of range
inT32 max_height, //top of range
inT32 *modes, //output array
inT32 maxmodes //size of modes
) {
INT32 pile_count; //no in source pile
INT32 src_count; //no of source entries
INT32 src_index; //current entry
INT32 least_count; //height of smalllest
INT32 least_index; //index of least
INT32 dest_count; //index in modes
inT32 pile_count; //no in source pile
inT32 src_count; //no of source entries
inT32 src_index; //current entry
inT32 least_count; //height of smalllest
inT32 least_index; //index of least
inT32 dest_count; //index in modes
src_count = max_height + 1 - min_height;
dest_count = 0;
@ -1685,7 +1685,7 @@ void separate_underlines( //make rough chars
C_BLOB *rotated_blob; //rotated blob
TO_ROW *row; //current row
float length; //of g_vec
BOX blob_box;
TBOX blob_box;
FCOORD blob_rotation; //inverse of rotation
FCOORD g_vec; //skew rotation
BLOBNBOX_IT blob_it; //iterator
@ -1711,8 +1711,8 @@ void separate_underlines( //make rough chars
rotated_blob = crotate_cblob (blob->cblob (),
blob_rotation);
if (test_underline (testing_on && textord_show_final_rows,
rotated_blob, (INT16) row->intercept (),
(INT16) (block->line_size *
rotated_blob, (inT16) row->intercept (),
(inT16) (block->line_size *
(textord_merge_x +
textord_merge_asc / 2.0f)))) {
under_it.add_after_then_move (blob_it.extract ());
@ -1781,11 +1781,11 @@ void pre_associate_blobs( //make rough chars
#ifndef GRAPHICS_DISABLED
ScrollView::Color colour; //of boxes
#endif
INT16 overlap; //of adjacent boxes
inT16 overlap; //of adjacent boxes
BLOBNBOX *blob; //current blob
BLOBNBOX *nextblob; //next in list
BOX blob_box;
BOX next_box; //next blob
TBOX blob_box;
TBOX next_box; //next blob
FCOORD blob_rotation; //inverse of rotation
BLOBNBOX_IT blob_it; //iterator
BLOBNBOX_IT start_it; //iterator
@ -1845,7 +1845,7 @@ void pre_associate_blobs( //make rough chars
if (testing_on && textord_show_final_blobs) {
if (to_win == NULL)
create_to_win(page_tr);
to_win->Pen(colour);
to_win->Pen(colour);
for (blob_it.mark_cycle_pt (); !blob_it.cycled_list ();
blob_it.forward ()) {
blob = blob_it.data ();
@ -1875,7 +1875,7 @@ void fit_parallel_rows( //find lines
TO_BLOCK *block, //block to do
float gradient, //gradient to fit
FCOORD rotation, //for drawing
INT32 block_edge, //edge of block
inT32 block_edge, //edge of block
BOOL8 testing_on //correct orientation
) {
#ifndef GRAPHICS_DISABLED
@ -1920,7 +1920,7 @@ void fit_parallel_lms( //sort function
) {
float c; //fitted line
int blobcount; //no of blobs
BOX box; //blob box
TBOX box; //blob box
LMS lms (row->blob_list ()->length ());
//blobs
BLOBNBOX_IT blob_it = row->blob_list ();
@ -1954,7 +1954,7 @@ void make_spline_rows( //find lines
TO_BLOCK *block, //block to do
float gradient, //gradient to fit
FCOORD rotation, //for drawing
INT32 block_edge, //edge of block
inT32 block_edge, //edge of block
BOOL8 testing_on //correct orientation
) {
#ifndef GRAPHICS_DISABLED
@ -2012,17 +2012,17 @@ void make_baseline_spline( //sort function
) {
float b, c; //fitted curve
float middle; //x middle of blob
BOX box; //blob box
TBOX box; //blob box
LMS lms (row->blob_list ()->length ());
//blobs
BLOBNBOX_IT blob_it = row->blob_list ();
INT32 *xstarts; //spline boundaries
inT32 *xstarts; //spline boundaries
double *coeffs; //quadratic coeffs
INT32 segments; //no of segments
INT32 segment; //current segment
inT32 segments; //no of segments
inT32 segment; //current segment
xstarts =
(INT32 *) alloc_mem ((row->blob_list ()->length () + 1) * sizeof (INT32));
(inT32 *) alloc_mem ((row->blob_list ()->length () + 1) * sizeof (inT32));
if (segment_baseline (row, block, segments, xstarts)
&& !textord_straight_baselines && !textord_parallel_baselines) {
if (textord_quadratic_baselines) {
@ -2081,8 +2081,8 @@ BOOL8
segment_baseline ( //split baseline
TO_ROW * row, //row to fit
TO_BLOCK * block, //block it came from
INT32 & segments, //no fo segments
INT32 xstarts[] //coords of segments
inT32 & segments, //no fo segments
inT32 xstarts[] //coords of segments
) {
BOOL8 needs_curve; //needs curved line
int blobcount; //no of blobs
@ -2090,8 +2090,8 @@ INT32 xstarts[] //coords of segments
int last_state; //above, on , below
int state; //of current blob
float yshift; //from baseline
BOX box; //blob box
BOX new_box; //new_it box
TBOX box; //blob box
TBOX new_box; //new_it box
float middle; //xcentre of blob
//blobs
BLOBNBOX_IT blob_it = row->blob_list ();
@ -2181,15 +2181,15 @@ double *
linear_spline_baseline ( //split baseline
TO_ROW * row, //row to fit
TO_BLOCK * block, //block it came from
INT32 & segments, //no fo segments
INT32 xstarts[] //coords of segments
inT32 & segments, //no fo segments
inT32 xstarts[] //coords of segments
) {
int blobcount; //no of blobs
int blobindex; //current blob
int index1, index2; //blob numbers
int blobs_per_segment; //blobs in each
BOX box; //blob box
BOX new_box; //new_it box
TBOX box; //blob box
TBOX new_box; //new_it box
float middle; //xcentre of blob
//blobs
BLOBNBOX_IT blob_it = row->blob_list ();
@ -2197,7 +2197,7 @@ INT32 xstarts[] //coords of segments
float b, c; //fitted curve
LMS lms (row->blob_list ()->length ());
double *coeffs; //quadratic coeffs
INT32 segment; //current segment
inT32 segment; //current segment
box = box_next_pre_chopped (&blob_it);
xstarts[0] = box.left ();
@ -2283,9 +2283,9 @@ void assign_blobs_to_rows( //find lines
float ycoord; //current y
float top, bottom; //of blob
float g_length = 1.0f; //from gradient
INT16 row_count; //no of rows
INT16 left_x; //left edge
INT16 last_x; //previous edge
inT16 row_count; //no of rows
inT16 left_x; //left edge
inT16 last_x; //previous edge
float block_skew; //y delta
float smooth_factor; //for new coords
float near_dist; //dist to nearest row

View File

@ -134,54 +134,54 @@ void cleanup_rows( //find lines
TO_BLOCK *block, //block to do
float gradient, //gradient to fit
FCOORD rotation, //for drawing
INT32 block_edge, //edge of block
inT32 block_edge, //edge of block
BOOL8 testing_on //correct orientation
);
void delete_non_dropout_rows( //find lines
TO_BLOCK *block, //block to do
float gradient, //global skew
FCOORD rotation, //deskew vector
INT32 block_edge, //left edge
inT32 block_edge, //left edge
BOOL8 testing_on //correct orientation
);
BOOL8 find_best_dropout_row( //find neighbours
TO_ROW *row, //row to test
INT32 distance, //dropout dist
inT32 distance, //dropout dist
float dist_limit, //threshold distance
INT32 line_index, //index of row
inT32 line_index, //index of row
TO_ROW_IT *row_it, //current position
BOOL8 testing_on //correct orientation
);
BOX deskew_block_coords( //block box
TBOX deskew_block_coords( //block box
TO_BLOCK *block, //block to do
float gradient //global skew
);
void compute_line_occupation( //project blobs
TO_BLOCK *block, //block to do
float gradient, //global skew
INT32 min_y, //min coord in block
INT32 max_y, //in block
INT32 *occupation, //output projection
INT32 *deltas //derivative
inT32 min_y, //min coord in block
inT32 max_y, //in block
inT32 *occupation, //output projection
inT32 *deltas //derivative
);
void compute_occupation_threshold( //project blobs
INT32 low_window, //below result point
INT32 high_window, //above result point
INT32 line_count, //array sizes
INT32 *occupation, //input projection
INT32 *thresholds //output thresholds
inT32 low_window, //below result point
inT32 high_window, //above result point
inT32 line_count, //array sizes
inT32 *occupation, //input projection
inT32 *thresholds //output thresholds
);
void compute_dropout_distances( //project blobs
INT32 *occupation, //input projection
INT32 *thresholds, //output thresholds
INT32 line_count //array sizes
inT32 *occupation, //input projection
inT32 *thresholds, //output thresholds
inT32 line_count //array sizes
);
void expand_rows( //find lines
ICOORD page_tr, //top right
TO_BLOCK *block, //block to do
float gradient, //gradient to fit
FCOORD rotation, //for drawing
INT32 block_edge, //edge of block
inT32 block_edge, //edge of block
BOOL8 testing_on //correct orientation
);
void adjust_row_limits( //tidy limits
@ -199,22 +199,22 @@ float median_block_xheight( //find lines
TO_BLOCK *block, //block to do
float gradient //global skew
);
INT32 compute_row_xheight( //find lines
inT32 compute_row_xheight( //find lines
TO_ROW *row, //row to do
INT32 min_height, //min xheight
INT32 max_height, //max xheight
inT32 min_height, //min xheight
inT32 max_height, //max xheight
float gradient //global skew
);
INT32 compute_row_descdrop( //find lines
inT32 compute_row_descdrop( //find lines
TO_ROW *row, //row to do
float gradient //global skew
);
INT32 compute_height_modes( //find lines
inT32 compute_height_modes( //find lines
STATS *heights, //stats to search
INT32 min_height, //bottom of range
INT32 max_height, //top of range
INT32 *modes, //output array
INT32 maxmodes //size of modes
inT32 min_height, //bottom of range
inT32 max_height, //top of range
inT32 *modes, //output array
inT32 maxmodes //size of modes
);
void correct_row_xheight( //fix bad values
TO_ROW *row, //row to fix
@ -237,7 +237,7 @@ void fit_parallel_rows( //find lines
TO_BLOCK *block, //block to do
float gradient, //gradient to fit
FCOORD rotation, //for drawing
INT32 block_edge, //edge of block
inT32 block_edge, //edge of block
BOOL8 testing_on //correct orientation
);
void fit_parallel_lms( //sort function
@ -248,7 +248,7 @@ void make_spline_rows( //find lines
TO_BLOCK *block, //block to do
float gradient, //gradient to fit
FCOORD rotation, //for drawing
INT32 block_edge, //edge of block
inT32 block_edge, //edge of block
BOOL8 testing_on //correct orientation
);
void make_baseline_spline( //sort function
@ -258,14 +258,14 @@ void make_baseline_spline( //sort function
BOOL8 segment_baseline ( //split baseline
TO_ROW * row, //row to fit
TO_BLOCK * block, //block it came from
INT32 & segments, //no fo segments
INT32 xstarts[] //coords of segments
inT32 & segments, //no fo segments
inT32 xstarts[] //coords of segments
);
double *linear_spline_baseline ( //split baseline
TO_ROW * row, //row to fit
TO_BLOCK * block, //block it came from
INT32 & segments, //no fo segments
INT32 xstarts[] //coords of segments
inT32 & segments, //no fo segments
inT32 xstarts[] //coords of segments
);
void assign_blobs_to_rows( //find lines
TO_BLOCK *block, //block to do

View File

@ -338,7 +338,7 @@ void find_textlines( //get baseline
float jumplimit; /*allowed delta change */
int *xcoords; /*useful sample points */
int *ycoords; /*useful sample points */
BOX *blobcoords; /*edges of blob rectangles */
TBOX *blobcoords; /*edges of blob rectangles */
int blobcount; /*no of blobs on line */
float *ydiffs; /*diffs from 1st approx */
int pointcount; /*no of coords */
@ -350,7 +350,7 @@ void find_textlines( //get baseline
partids = (char *) alloc_mem (blobcount * sizeof (char));
xcoords = (int *) alloc_mem (blobcount * sizeof (int));
ycoords = (int *) alloc_mem (blobcount * sizeof (int));
blobcoords = (BOX *) alloc_mem (blobcount * sizeof (BOX));
blobcoords = (TBOX *) alloc_mem (blobcount * sizeof (TBOX));
ydiffs = (float *) alloc_mem (blobcount * sizeof (float));
lineheight = get_blob_coords (row, (int) block->line_size, blobcoords,
@ -433,8 +433,8 @@ void find_textlines( //get baseline
int get_blob_coords( //get boxes
TO_ROW *row, //row to use
INT32 lineheight, //block level
BOX *blobcoords, //ouput boxes
inT32 lineheight, //block level
TBOX *blobcoords, //ouput boxes
BOOL8 &holed_line, //lost a lot of blobs
int &outcount //no of real blobs
) {
@ -502,7 +502,7 @@ int get_blob_coords( //get boxes
void
make_first_baseline ( //initial approximation
BOX blobcoords[], /*blob bounding boxes */
TBOX blobcoords[], /*blob bounding boxes */
int blobcount, /*no of blobcoords */
int xcoords[], /*coords for spline */
int ycoords[], /*approximator */
@ -628,7 +628,7 @@ float jumplimit /*guess half descenders */
}
else {
*baseline = *spline; /*copy it */
shift = ICOORD (0, (INT16) (blobcoords[0].bottom ()
shift = ICOORD (0, (inT16) (blobcoords[0].bottom ()
- spline->y (blobcoords[0].right ())));
baseline->move (shift);
}
@ -645,7 +645,7 @@ float jumplimit /*guess half descenders */
void
make_holed_baseline ( //initial approximation
BOX blobcoords[], /*blob bounding boxes */
TBOX blobcoords[], /*blob bounding boxes */
int blobcount, /*no of blobcoords */
QSPLINE * spline, /*initial spline */
QSPLINE * baseline, /*output spline */
@ -658,7 +658,7 @@ float gradient //of line
ICOORD shift; //shift of spline
LMS lms(blobcount); //straight baseline
INT32 xstarts[2]; //straight line
inT32 xstarts[2]; //straight line
double coeffs[3];
float c; //line parameter
@ -686,7 +686,7 @@ float gradient //of line
- MAXOVERLAP * (rightedge - leftedge)) {
*baseline = *spline; /*copy it */
x = (leftedge + rightedge) / 2.0;
shift = ICOORD (0, (INT16) (gradient * x + c - spline->y (x)));
shift = ICOORD (0, (inT16) (gradient * x + c - spline->y (x)));
baseline->move (shift);
}
}
@ -703,7 +703,7 @@ float gradient //of line
int
partition_line ( //partition blobs
BOX blobcoords[], //bounding boxes
TBOX blobcoords[], //bounding boxes
int blobcount, /*no of blobs on row */
int *numparts, /*number of partitions */
char partids[], /*partition no of each blob */
@ -780,7 +780,7 @@ float ydiffs[] /*diff from spline */
void
merge_oldbl_parts ( //partition blobs
BOX blobcoords[], //bounding boxes
TBOX blobcoords[], //bounding boxes
int blobcount, /*no of blobs on row */
char partids[], /*partition no of each blob */
int partsizes[], /*no in each partition */
@ -893,7 +893,7 @@ float jumplimit /*allowed delta change */
int
get_ydiffs ( //evaluate differences
BOX blobcoords[], //bounding boxes
TBOX blobcoords[], //bounding boxes
int blobcount, /*no of blobs */
QSPLINE * spline, /*approximating spline */
float ydiffs[] /*output */
@ -1071,7 +1071,7 @@ int *partcount /*no of partitions */
int
partition_coords ( //find relevant coords
BOX blobcoords[], //bounding boxes
TBOX blobcoords[], //bounding boxes
int blobcount, /*no of blobs in row */
char partids[], /*partition no of each blob */
int bestpart, /*best new partition */
@ -1102,7 +1102,7 @@ int ycoords[] /*points to work on */
int
segment_spline ( //make xstarts
BOX blobcoords[], //boundign boxes
TBOX blobcoords[], //boundign boxes
int blobcount, /*no of blobs in row */
int xcoords[], /*points to work on */
int ycoords[], /*points to work on */
@ -1314,7 +1314,7 @@ int &segments //no of segments
tprintf
("Resegmenting spline failed - insufficient pts (%d,%d,%d,%d)\n",
startindex, centreindex, endindex,
(INT32) textord_spline_medianwin);
(inT32) textord_spline_medianwin);
}
}
// else tprintf("Spline step at %d is %g\n",
@ -1359,7 +1359,7 @@ int coord2, int &segments //total segments
void
find_lesser_parts ( //get descenders
TO_ROW * row, //row to process
BOX blobcoords[], //bounding boxes
TBOX blobcoords[], //bounding boxes
int blobcount, /*no of blobs */
char partids[], /*partition of each blob */
int partsizes[], /*size of each part */
@ -1444,7 +1444,7 @@ int bestpart /*biggest partition */
void
old_first_xheight ( //the wiseowl way
TO_ROW * row, /*current row */
BOX blobcoords[], /*blob bounding boxes */
TBOX blobcoords[], /*blob bounding boxes */
int initialheight, //initial guess
int blobcount, /*blobs in blobcoords */
QSPLINE * baseline, /*established */
@ -1529,7 +1529,7 @@ float jumplimit /*min ascender height */
void
make_first_xheight ( //find xheight
TO_ROW * row, /*current row */
BOX blobcoords[], /*blob bounding boxes */
TBOX blobcoords[], /*blob bounding boxes */
int lineheight, //initial guess
int init_lineheight, //block level guess
int blobcount, /*blobs in blobcoords */

View File

@ -65,13 +65,13 @@ void find_textlines( //get baseline
);
int get_blob_coords( //get boxes
TO_ROW *row, //row to use
INT32 lineheight, //block level
BOX *blobcoords, //ouput boxes
inT32 lineheight, //block level
TBOX *blobcoords, //ouput boxes
BOOL8 &holed_line, //lost a lot of blobs
int &outcount //no of real blobs
);
void make_first_baseline ( //initial approximation
BOX blobcoords[], /*blob bounding boxes */
TBOX blobcoords[], /*blob bounding boxes */
int blobcount, /*no of blobcoords */
int xcoords[], /*coords for spline */
int ycoords[], /*approximator */
@ -80,14 +80,14 @@ QSPLINE * baseline, /*output spline */
float jumplimit /*guess half descenders */
);
void make_holed_baseline ( //initial approximation
BOX blobcoords[], /*blob bounding boxes */
TBOX blobcoords[], /*blob bounding boxes */
int blobcount, /*no of blobcoords */
QSPLINE * spline, /*initial spline */
QSPLINE * baseline, /*output spline */
float gradient //of line
);
int partition_line ( //partition blobs
BOX blobcoords[], //bounding boxes
TBOX blobcoords[], //bounding boxes
int blobcount, /*no of blobs on row */
int *numparts, /*number of partitions */
char partids[], /*partition no of each blob */
@ -97,7 +97,7 @@ float jumplimit, /*allowed delta change */
float ydiffs[] /*diff from spline */
);
void merge_oldbl_parts ( //partition blobs
BOX blobcoords[], //bounding boxes
TBOX blobcoords[], //bounding boxes
int blobcount, /*no of blobs on row */
char partids[], /*partition no of each blob */
int partsizes[], /*no in each partition */
@ -105,7 +105,7 @@ int biggestpart, //major partition
float jumplimit /*allowed delta change */
);
int get_ydiffs ( //evaluate differences
BOX blobcoords[], //bounding boxes
TBOX blobcoords[], //bounding boxes
int blobcount, /*no of blobs */
QSPLINE * spline, /*approximating spline */
float ydiffs[] /*output */
@ -118,7 +118,7 @@ float jumplimit, /*new part threshold */
int *partcount /*no of partitions */
);
int partition_coords ( //find relevant coords
BOX blobcoords[], //bounding boxes
TBOX blobcoords[], //bounding boxes
int blobcount, /*no of blobs in row */
char partids[], /*partition no of each blob */
int bestpart, /*best new partition */
@ -126,7 +126,7 @@ int xcoords[], /*points to work on */
int ycoords[] /*points to work on */
);
int segment_spline ( //make xstarts
BOX blobcoords[], //boundign boxes
TBOX blobcoords[], //boundign boxes
int blobcount, /*no of blobs in row */
int xcoords[], /*points to work on */
int ycoords[], /*points to work on */
@ -148,7 +148,7 @@ int coord2, int &segments //total segments
);
void find_lesser_parts ( //get descenders
TO_ROW * row, //row to process
BOX blobcoords[], //bounding boxes
TBOX blobcoords[], //bounding boxes
int blobcount, /*no of blobs */
char partids[], /*partition of each blob */
int partsizes[], /*size of each part */
@ -158,7 +158,7 @@ int bestpart /*biggest partition */
void old_first_xheight ( //the wiseowl way
TO_ROW * row, /*current row */
BOX blobcoords[], /*blob bounding boxes */
TBOX blobcoords[], /*blob bounding boxes */
int initialheight, //initial guess
int blobcount, /*blobs in blobcoords */
QSPLINE * baseline, /*established */
@ -167,7 +167,7 @@ float jumplimit /*min ascender height */
void make_first_xheight ( //find xheight
TO_ROW * row, /*current row */
BOX blobcoords[], /*blob bounding boxes */
TBOX blobcoords[], /*blob bounding boxes */
int lineheight, //initial guess
int init_lineheight, //block level guess
int blobcount, /*blobs in blobcoords */
@ -176,7 +176,7 @@ float jumplimit /*min ascender height */
);
int *make_height_array ( //get array of heights
BOX blobcoords[], /*blob bounding boxes */
TBOX blobcoords[], /*blob bounding boxes */
int blobcount, /*blobs in blobcoords */
QSPLINE * baseline /*established */
);

View File

@ -41,17 +41,17 @@
void FPCUTPT::setup( //constructor
FPCUTPT *cutpts, //predecessors
INT16 array_origin, //start coord
inT16 array_origin, //start coord
STATS *projection, //vertical occupation
INT16 zero_count, //official zero
INT16 pitch, //proposed pitch
INT16 x, //position
INT16 offset //dist to gap
inT16 zero_count, //official zero
inT16 pitch, //proposed pitch
inT16 x, //position
inT16 offset //dist to gap
) {
//half of pitch
INT16 half_pitch = pitch / 2 - 1;
UINT32 lead_flag; //new flag
INT32 ind; //current position
inT16 half_pitch = pitch / 2 - 1;
uinT32 lead_flag; //new flag
inT32 ind; //current position
if (half_pitch > 31)
half_pitch = 31;
@ -98,30 +98,30 @@ void FPCUTPT::setup( //constructor
void FPCUTPT::assign( //constructor
FPCUTPT *cutpts, //predecessors
INT16 array_origin, //start coord
INT16 x, //position
inT16 array_origin, //start coord
inT16 x, //position
BOOL8 faking, //faking this one
BOOL8 mid_cut, //cheap cut.
INT16 offset, //dist to gap
inT16 offset, //dist to gap
STATS *projection, //vertical occupation
float projection_scale, //scaling
INT16 zero_count, //official zero
INT16 pitch, //proposed pitch
INT16 pitch_error //allowed tolerance
inT16 zero_count, //official zero
inT16 pitch, //proposed pitch
inT16 pitch_error //allowed tolerance
) {
int index; //test index
int balance_index; //for balance factor
INT16 balance_count; //ding factor
INT16 r_index; //test cut number
inT16 balance_count; //ding factor
inT16 r_index; //test cut number
FPCUTPT *segpt; //segment point
INT32 dist; //from prev segment
inT32 dist; //from prev segment
double sq_dist; //squared distance
double mean; //mean pitch
double total; //total dists
double factor; //cost function
//half of pitch
INT16 half_pitch = pitch / 2 - 1;
UINT32 lead_flag; //new flag
inT16 half_pitch = pitch / 2 - 1;
uinT32 lead_flag; //new flag
if (half_pitch > 31)
half_pitch = 31;
@ -171,7 +171,7 @@ void FPCUTPT::assign( //constructor
<= zero_count);
}
balance_count =
(INT16) (balance_count * textord_balance_factor /
(inT16) (balance_count * textord_balance_factor /
projection_scale);
}
r_index = segpt->region_index + 1;
@ -206,29 +206,29 @@ void FPCUTPT::assign( //constructor
void FPCUTPT::assign_cheap( //constructor
FPCUTPT *cutpts, //predecessors
INT16 array_origin, //start coord
INT16 x, //position
inT16 array_origin, //start coord
inT16 x, //position
BOOL8 faking, //faking this one
BOOL8 mid_cut, //cheap cut.
INT16 offset, //dist to gap
inT16 offset, //dist to gap
STATS *projection, //vertical occupation
float projection_scale, //scaling
INT16 zero_count, //official zero
INT16 pitch, //proposed pitch
INT16 pitch_error //allowed tolerance
inT16 zero_count, //official zero
inT16 pitch, //proposed pitch
inT16 pitch_error //allowed tolerance
) {
int index; //test index
INT16 balance_count; //ding factor
INT16 r_index; //test cut number
inT16 balance_count; //ding factor
inT16 r_index; //test cut number
FPCUTPT *segpt; //segment point
INT32 dist; //from prev segment
inT32 dist; //from prev segment
double sq_dist; //squared distance
double mean; //mean pitch
double total; //total dists
double factor; //cost function
//half of pitch
INT16 half_pitch = pitch / 2 - 1;
UINT32 lead_flag; //new flag
inT16 half_pitch = pitch / 2 - 1;
uinT32 lead_flag; //new flag
if (half_pitch > 31)
half_pitch = 31;
@ -264,7 +264,7 @@ void FPCUTPT::assign_cheap( //constructor
balance_count++;
lead_flag &= lead_flag - 1;
}
balance_count = (INT16) (balance_count * textord_balance_factor
balance_count = (inT16) (balance_count * textord_balance_factor
/ projection_scale);
}
r_index = segpt->region_index + 1;
@ -298,38 +298,38 @@ void FPCUTPT::assign_cheap( //constructor
double check_pitch_sync2( //find segmentation
BLOBNBOX_IT *blob_it, //blobs to do
INT16 blob_count, //no of blobs
INT16 pitch, //pitch estimate
INT16 pitch_error, //tolerance
inT16 blob_count, //no of blobs
inT16 pitch, //pitch estimate
inT16 pitch_error, //tolerance
STATS *projection, //vertical
INT16 projection_left, //edges //scale factor
INT16 projection_right,
inT16 projection_left, //edges //scale factor
inT16 projection_right,
float projection_scale,
INT16 &occupation_count, //no of occupied cells
inT16 &occupation_count, //no of occupied cells
FPSEGPT_LIST *seg_list, //output list
INT16 start, //start of good range
INT16 end //end of good range
inT16 start, //start of good range
inT16 end //end of good range
) {
BOOL8 faking; //illegal cut pt
BOOL8 mid_cut; //cheap cut pt.
INT16 x; //current coord
INT16 blob_index; //blob number
INT16 left_edge; //of word
INT16 right_edge; //of word
INT16 array_origin; //x coord of array
INT16 offset; //dist to legal area
INT16 zero_count; //projection zero
INT16 best_left_x = 0; //for equals
INT16 best_right_x = 0; //right edge
BOX this_box; //bounding box
BOX next_box; //box of next blob
inT16 x; //current coord
inT16 blob_index; //blob number
inT16 left_edge; //of word
inT16 right_edge; //of word
inT16 array_origin; //x coord of array
inT16 offset; //dist to legal area
inT16 zero_count; //projection zero
inT16 best_left_x = 0; //for equals
inT16 best_right_x = 0; //right edge
TBOX this_box; //bounding box
TBOX next_box; //box of next blob
FPSEGPT *segpt; //segment point
FPCUTPT *cutpts; //array of points
double best_cost; //best path
double mean_sum; //computes result
FPCUTPT *best_end; //end of best path
INT16 best_fake; //best fake level
INT16 best_count; //no of cuts
inT16 best_fake; //best fake level
inT16 best_count; //no of cuts
BLOBNBOX_IT this_it; //copy iterator
FPSEGPT_IT seg_it = seg_list; //output iterator
@ -477,7 +477,7 @@ double check_pitch_sync2( //find segmentation
if (seg_it.data ()->squares () - mean_sum < 0)
tprintf ("Impossible sqsum=%g, mean=%g, total=%d\n",
seg_it.data ()->squares (), seg_it.data ()->sum (), best_count);
free_mem(cutpts);
free_mem(cutpts);
// tprintf("blob_count=%d, pitch=%d, sync=%g, occ=%d\n",
// blob_count,pitch,seg_it.data()->squares()-mean_sum,
// occupation_count);
@ -494,31 +494,31 @@ double check_pitch_sync2( //find segmentation
**********************************************************************/
double check_pitch_sync3( //find segmentation
INT16 projection_left, //edges //to be considered 0
INT16 projection_right,
INT16 zero_count,
INT16 pitch, //pitch estimate
INT16 pitch_error, //tolerance
inT16 projection_left, //edges //to be considered 0
inT16 projection_right,
inT16 zero_count,
inT16 pitch, //pitch estimate
inT16 pitch_error, //tolerance
STATS *projection, //vertical
float projection_scale, //scale factor
INT16 &occupation_count, //no of occupied cells
inT16 &occupation_count, //no of occupied cells
FPSEGPT_LIST *seg_list, //output list
INT16 start, //start of good range
INT16 end //end of good range
inT16 start, //start of good range
inT16 end //end of good range
) {
BOOL8 faking; //illegal cut pt
BOOL8 mid_cut; //cheap cut pt.
INT16 left_edge; //of word
INT16 right_edge; //of word
INT16 x; //current coord
INT16 array_origin; //x coord of array
INT16 offset; //dist to legal area
INT16 projection_offset; //from scaled projection
INT16 prev_zero; //previous zero dist
INT16 next_zero; //next zero dist
INT16 zero_offset; //scan window
INT16 best_left_x = 0; //for equals
INT16 best_right_x = 0; //right edge
inT16 left_edge; //of word
inT16 right_edge; //of word
inT16 x; //current coord
inT16 array_origin; //x coord of array
inT16 offset; //dist to legal area
inT16 projection_offset; //from scaled projection
inT16 prev_zero; //previous zero dist
inT16 next_zero; //next zero dist
inT16 zero_offset; //scan window
inT16 best_left_x = 0; //for equals
inT16 best_right_x = 0; //right edge
FPSEGPT *segpt; //segment point
FPCUTPT *cutpts; //array of points
BOOL8 *mins; //local min results
@ -527,8 +527,8 @@ double check_pitch_sync3( //find segmentation
double best_cost; //best path
double mean_sum; //computes result
FPCUTPT *best_end; //end of best path
INT16 best_fake; //best fake level
INT16 best_count; //no of cuts
inT16 best_fake; //best fake level
inT16 best_count; //no of cuts
FPSEGPT_IT seg_it = seg_list; //output iterator
end = (end - start) % pitch;
@ -537,7 +537,7 @@ double check_pitch_sync3( //find segmentation
if ((pitch - 3) / 2 < pitch_error)
pitch_error = (pitch - 3) / 2;
//min dist of zero
zero_offset = (INT16) (pitch * pitsync_joined_edge);
zero_offset = (inT16) (pitch * pitsync_joined_edge);
for (left_edge = projection_left; projection->pile_count (left_edge) == 0
&& left_edge < projection_right; left_edge++);
for (right_edge = projection_right; projection->pile_count (right_edge) == 0
@ -604,7 +604,7 @@ double check_pitch_sync3( //find segmentation
}
else {
projection_offset =
(INT16) (projection->pile_count (x) / projection_scale);
(inT16) (projection->pile_count (x) / projection_scale);
if (projection_offset > offset)
offset = projection_offset;
mid_cut = TRUE;
@ -690,7 +690,7 @@ double check_pitch_sync3( //find segmentation
if (seg_it.data ()->squares () - mean_sum < 0)
tprintf ("Impossible sqsum=%g, mean=%g, total=%d\n",
seg_it.data ()->squares (), seg_it.data ()->sum (), best_count);
free_mem(mins);
free_mem(cutpts);
free_mem(mins);
free_mem(cutpts);
return seg_it.data ()->squares () - mean_sum;
}

View File

@ -34,71 +34,71 @@ class FPCUTPT
}
void setup ( //start of cut
FPCUTPT cutpts[], //predecessors
INT16 array_origin, //start coord
inT16 array_origin, //start coord
STATS * projection, //occupation
INT16 zero_count, //official zero
INT16 pitch, //proposed pitch
INT16 x, //position
INT16 offset); //dist to gap
inT16 zero_count, //official zero
inT16 pitch, //proposed pitch
inT16 x, //position
inT16 offset); //dist to gap
void assign ( //evaluate cut
FPCUTPT cutpts[], //predecessors
INT16 array_origin, //start coord
INT16 x, //position
inT16 array_origin, //start coord
inT16 x, //position
BOOL8 faking, //faking this one
BOOL8 mid_cut, //doing free cut
INT16 offset, //extra cost dist
inT16 offset, //extra cost dist
STATS * projection, //occupation
float projection_scale, //scaling
INT16 zero_count, //official zero
INT16 pitch, //proposed pitch
INT16 pitch_error); //allowed tolerance
inT16 zero_count, //official zero
inT16 pitch, //proposed pitch
inT16 pitch_error); //allowed tolerance
void assign_cheap ( //evaluate cut
FPCUTPT cutpts[], //predecessors
INT16 array_origin, //start coord
INT16 x, //position
inT16 array_origin, //start coord
inT16 x, //position
BOOL8 faking, //faking this one
BOOL8 mid_cut, //doing free cut
INT16 offset, //extra cost dist
inT16 offset, //extra cost dist
STATS * projection, //occupation
float projection_scale, //scaling
INT16 zero_count, //official zero
INT16 pitch, //proposed pitch
INT16 pitch_error); //allowed tolerance
inT16 zero_count, //official zero
inT16 pitch, //proposed pitch
inT16 pitch_error); //allowed tolerance
INT32 position() { //acces func
inT32 position() { //acces func
return xpos;
}
double cost_function() {
double cost_function() {
return cost;
}
double squares() {
double squares() {
return sq_sum;
}
double sum() {
double sum() {
return mean_sum;
}
FPCUTPT *previous() {
FPCUTPT *previous() {
return pred;
}
INT16 cheap_cuts() const { //no of mi cuts
inT16 cheap_cuts() const { //no of mi cuts
return mid_cuts;
}
INT16 index() const {
inT16 index() const {
return region_index;
}
BOOL8 faked; //faked split point
BOOL8 terminal; //successful end
INT16 fake_count; //total fakes to here
inT16 fake_count; //total fakes to here
private:
INT16 region_index; //cut serial number
INT16 mid_cuts; //no of cheap cuts
INT32 xpos; //location
UINT32 back_balance; //proj backwards
UINT32 fwd_balance; //proj forwards
inT16 region_index; //cut serial number
inT16 mid_cuts; //no of cheap cuts
inT32 xpos; //location
uinT32 back_balance; //proj backwards
uinT32 fwd_balance; //proj forwards
FPCUTPT *pred; //optimal previous
double mean_sum; //mean so far
double sq_sum; //summed distsances
@ -106,29 +106,29 @@ class FPCUTPT
};
double check_pitch_sync2( //find segmentation
BLOBNBOX_IT *blob_it, //blobs to do
INT16 blob_count, //no of blobs
INT16 pitch, //pitch estimate
INT16 pitch_error, //tolerance
inT16 blob_count, //no of blobs
inT16 pitch, //pitch estimate
inT16 pitch_error, //tolerance
STATS *projection, //vertical
INT16 projection_left, //edges //scale factor
INT16 projection_right,
inT16 projection_left, //edges //scale factor
inT16 projection_right,
float projection_scale,
INT16 &occupation_count, //no of occupied cells
inT16 &occupation_count, //no of occupied cells
FPSEGPT_LIST *seg_list, //output list
INT16 start, //start of good range
INT16 end //end of good range
inT16 start, //start of good range
inT16 end //end of good range
);
double check_pitch_sync3( //find segmentation
INT16 projection_left, //edges //to be considered 0
INT16 projection_right,
INT16 zero_count,
INT16 pitch, //pitch estimate
INT16 pitch_error, //tolerance
inT16 projection_left, //edges //to be considered 0
inT16 projection_right,
inT16 zero_count,
inT16 pitch, //pitch estimate
inT16 pitch_error, //tolerance
STATS *projection, //vertical
float projection_scale, //scale factor
INT16 &occupation_count, //no of occupied cells
inT16 &occupation_count, //no of occupied cells
FPSEGPT_LIST *seg_list, //output list
INT16 start, //start of good range
INT16 end //end of good range
inT16 start, //start of good range
inT16 end //end of good range
);
#endif

View File

@ -69,7 +69,7 @@ FPSEGPT::FPSEGPT( //constructor
**********************************************************************/
FPSEGPT::FPSEGPT ( //constructor
INT16 x //position
inT16 x //position
):xpos (x) {
pred = NULL;
mean_sum = 0;
@ -89,17 +89,17 @@ INT16 x //position
**********************************************************************/
FPSEGPT::FPSEGPT ( //constructor
INT16 x, //position
inT16 x, //position
BOOL8 faking, //faking this one
INT16 offset, //dist to gap
INT16 region_index, //segment number
INT16 pitch, //proposed pitch
INT16 pitch_error, //allowed tolerance
inT16 offset, //dist to gap
inT16 region_index, //segment number
inT16 pitch, //proposed pitch
inT16 pitch_error, //allowed tolerance
FPSEGPT_LIST * prev_list //previous segment
):xpos (x) {
INT16 best_fake; //on previous
inT16 best_fake; //on previous
FPSEGPT *segpt; //segment point
INT32 dist; //from prev segment
inT32 dist; //from prev segment
double sq_dist; //squared distance
double mean; //mean pitch
double total; //total dists
@ -150,28 +150,28 @@ FPSEGPT_LIST * prev_list //previous segment
double check_pitch_sync( //find segmentation
BLOBNBOX_IT *blob_it, //blobs to do
INT16 blob_count, //no of blobs
INT16 pitch, //pitch estimate
INT16 pitch_error, //tolerance
inT16 blob_count, //no of blobs
inT16 pitch, //pitch estimate
inT16 pitch_error, //tolerance
STATS *projection, //vertical
FPSEGPT_LIST *seg_list //output list
) {
INT16 x; //current coord
INT16 min_index; //blob number
INT16 max_index; //blob number
INT16 left_edge; //of word
INT16 right_edge; //of word
INT16 right_max; //max allowed x
INT16 min_x; //in this region
INT16 max_x;
INT16 region_index;
INT16 best_region_index = 0; //for best result
INT16 offset; //dist to legal area
INT16 left_best_x; //edge of good region
INT16 right_best_x; //right edge
BOX min_box; //bounding box
BOX max_box; //bounding box
BOX next_box; //box of next blob
inT16 x; //current coord
inT16 min_index; //blob number
inT16 max_index; //blob number
inT16 left_edge; //of word
inT16 right_edge; //of word
inT16 right_max; //max allowed x
inT16 min_x; //in this region
inT16 max_x;
inT16 region_index;
inT16 best_region_index = 0; //for best result
inT16 offset; //dist to legal area
inT16 left_best_x; //edge of good region
inT16 right_best_x; //right edge
TBOX min_box; //bounding box
TBOX max_box; //bounding box
TBOX next_box; //box of next blob
FPSEGPT *segpt; //segment point
FPSEGPT_LIST *segpts; //points in a segment
double best_cost; //best path
@ -368,17 +368,17 @@ double check_pitch_sync( //find segmentation
void make_illegal_segment( //find segmentation
FPSEGPT_LIST *prev_list, //previous segments
BOX blob_box, //bounding box
TBOX blob_box, //bounding box
BLOBNBOX_IT blob_it, //iterator
INT16 region_index, //number of segment
INT16 pitch, //pitch estimate
INT16 pitch_error, //tolerance
inT16 region_index, //number of segment
inT16 pitch, //pitch estimate
inT16 pitch_error, //tolerance
FPSEGPT_LIST *seg_list //output list
) {
INT16 x; //current coord
INT16 min_x = 0; //in this region
INT16 max_x = 0;
INT16 offset; //dist to edge
inT16 x; //current coord
inT16 min_x = 0; //in this region
inT16 max_x = 0;
inT16 offset; //dist to edge
FPSEGPT *segpt; //segment point
FPSEGPT *prevpt; //previous point
float best_cost; //best path

View File

@ -37,44 +37,44 @@ class FPSEGPT:public ELIST_LINK
FPSEGPT() { //empty
}
FPSEGPT( //constructor
INT16 x); //position
inT16 x); //position
FPSEGPT( //constructor
INT16 x, //position
inT16 x, //position
BOOL8 faking, //faking this one
INT16 offset, //extra cost dist
INT16 region_index, //segment number
INT16 pitch, //proposed pitch
INT16 pitch_error, //allowed tolerance
inT16 offset, //extra cost dist
inT16 region_index, //segment number
inT16 pitch, //proposed pitch
inT16 pitch_error, //allowed tolerance
FPSEGPT_LIST *prev_list); //previous segment
FPSEGPT(FPCUTPT *cutpt); //build from new type
INT32 position() { //acces func
inT32 position() { //acces func
return xpos;
}
double cost_function() {
double cost_function() {
return cost;
}
double squares() {
double squares() {
return sq_sum;
}
double sum() {
double sum() {
return mean_sum;
}
FPSEGPT *previous() {
FPSEGPT *previous() {
return pred;
}
INT16 cheap_cuts() const { //no of cheap cuts
inT16 cheap_cuts() const { //no of cheap cuts
return mid_cuts;
}
//faked split point
NEWDELETE2 (FPSEGPT) BOOL8 faked;
BOOL8 terminal; //successful end
INT16 fake_count; //total fakes to here
inT16 fake_count; //total fakes to here
private:
INT16 mid_cuts; //no of cheap cuts
INT32 xpos; //location
inT16 mid_cuts; //no of cheap cuts
inT32 xpos; //location
FPSEGPT *pred; //optimal previous
double mean_sum; //mean so far
double sq_sum; //summed distsances
@ -97,22 +97,22 @@ extern
INT_VAR_H (pitsync_fake_depth, 1, "Max advance fake generation");
double check_pitch_sync( //find segmentation
BLOBNBOX_IT *blob_it, //blobs to do
INT16 blob_count, //no of blobs
INT16 pitch, //pitch estimate
INT16 pitch_error, //tolerance
inT16 blob_count, //no of blobs
inT16 pitch, //pitch estimate
inT16 pitch_error, //tolerance
STATS *projection, //vertical
FPSEGPT_LIST *seg_list //output list
);
void make_illegal_segment( //find segmentation
FPSEGPT_LIST *prev_list, //previous segments
BOX blob_box, //bounding box
TBOX blob_box, //bounding box
BLOBNBOX_IT blob_it, //iterator
INT16 region_index, //number of segment
INT16 pitch, //pitch estimate
INT16 pitch_error, //tolerance
inT16 region_index, //number of segment
inT16 pitch, //pitch estimate
inT16 pitch_error, //tolerance
FPSEGPT_LIST *seg_list //output list
);
INT16 vertical_torow_projection( //project whole row
inT16 vertical_torow_projection( //project whole row
TO_ROW *row, //row to do
STATS *projection //output
);

View File

@ -46,9 +46,9 @@ DLLSYM void block_edges( //get edges in a block
PDBLK *block, //block in image
ICOORD page_tr //corner of page
) {
UINT8 margin; //margin colour
INT16 x; //line coords
INT16 y; //current line
uinT8 margin; //margin colour
inT16 x; //line coords
inT16 y; //current line
ICOORD bleft; //bounding box
ICOORD tright;
ICOORD block_bleft; //bounding box
@ -108,17 +108,17 @@ DLLSYM void block_edges( //get edges in a block
void make_margins( //get a line
PDBLK *block, //block in image
BLOCK_LINE_IT *line_it, //for old style
UINT8 *pixels, //pixels to strip
UINT8 margin, //white-out pixel
INT16 left, //block edges
INT16 right,
INT16 y //line coord
uinT8 *pixels, //pixels to strip
uinT8 margin, //white-out pixel
inT16 left, //block edges
inT16 right,
inT16 y //line coord
) {
PB_LINE_IT *lines;
ICOORDELT_LIST *segments; //bits of a line
ICOORDELT_IT seg_it;
INT32 start; //of segment
INT16 xext; //of segment
inT32 start; //of segment
inT16 xext; //of segment
int xindex; //index to pixel
if (block->poly_block () != NULL) {
@ -167,12 +167,12 @@ void whiteout_block( //clean it
IMAGE *t_image, //threshold image
PDBLK *block //block in image
) {
INT16 x; //line coords
INT16 y; //current line
INT16 xext; //line width
inT16 x; //line coords
inT16 y; //current line
inT16 xext; //line width
int xindex; //index to pixel
UINT8 *dest; //destination pixel
BOX block_box; //bounding box
uinT8 *dest; //destination pixel
TBOX block_box; //bounding box
BLOCK_LINE_IT line_it = block; //line iterator
IMAGELINE bwline; //thresholded line
@ -198,11 +198,11 @@ void whiteout_block( //clean it
void
line_edges ( //scan for edges
INT16 x, //coord of line start
INT16 y, //coord of line
INT16 xext, //width of line
UINT8 uppercolour, //start of prev line
UINT8 * bwpos, //thresholded line
inT16 x, //coord of line start
inT16 y, //coord of line
inT16 xext, //width of line
uinT8 uppercolour, //start of prev line
uinT8 * bwpos, //thresholded line
CRACKEDGE ** prevline //edges in progress
) {
int xpos; //current x coord
@ -288,9 +288,9 @@ CRACKEDGE ** prevline //edges in progress
CRACKEDGE *
h_edge ( //horizontal edge
INT16 x, //xposition
INT16 y, //y position
INT8 sign, //sign of edge
inT16 x, //xposition
inT16 y, //y position
inT8 sign, //sign of edge
CRACKEDGE * join //edge to join to
) {
CRACKEDGE *newpt; //return value
@ -348,9 +348,9 @@ CRACKEDGE * join //edge to join to
CRACKEDGE *
v_edge ( //vertical edge
INT16 x, //xposition
INT16 y, //y position
INT8 sign, //sign of edge
inT16 x, //xposition
inT16 y, //y position
inT8 sign, //sign of edge
CRACKEDGE * join //edge to join to
) {
CRACKEDGE *newpt; //return value

View File

@ -34,34 +34,34 @@ DLLSYM void block_edges( //get edges in a block
void make_margins( //get a line
PDBLK *block, //block in image
BLOCK_LINE_IT *line_it, //for old style
UINT8 *pixels, //pixels to strip
UINT8 margin, //white-out pixel
INT16 left, //block edges
INT16 right,
INT16 y //line coord
uinT8 *pixels, //pixels to strip
uinT8 margin, //white-out pixel
inT16 left, //block edges
inT16 right,
inT16 y //line coord
);
void whiteout_block( //clean it
IMAGE *t_image, //threshold image
PDBLK *block //block in image
);
void line_edges ( //scan for edges
INT16 x, //coord of line start
INT16 y, //coord of line
INT16 xext, //width of line
UINT8 uppercolour, //start of prev line
UINT8 * bwpos, //thresholded line
inT16 x, //coord of line start
inT16 y, //coord of line
inT16 xext, //width of line
uinT8 uppercolour, //start of prev line
uinT8 * bwpos, //thresholded line
CRACKEDGE ** prevline //edges in progress
);
CRACKEDGE *h_edge ( //horizontal edge
INT16 x, //xposition
INT16 y, //y position
INT8 sign, //sign of edge
inT16 x, //xposition
inT16 y, //y position
inT8 sign, //sign of edge
CRACKEDGE * join //edge to join to
);
CRACKEDGE *v_edge ( //vertical edge
INT16 x, //xposition
INT16 y, //y position
INT8 sign, //sign of edge
inT16 x, //xposition
inT16 y, //y position
inT8 sign, //sign of edge
CRACKEDGE * join //edge to join to
);
void join_edges( //join edge fragments

View File

@ -29,7 +29,7 @@ ELISTIZE (SORTED_FLOAT)
**********************************************************************/
void SORTED_FLOATS::add( //add new entry
float value,
INT32 key) {
inT32 key) {
SORTED_FLOAT *new_float = new SORTED_FLOAT (value, key);
if (list.empty ())
@ -53,7 +53,7 @@ void SORTED_FLOATS::add( //add new entry
**********************************************************************/
void SORTED_FLOATS::remove( //remove the entry
INT32 key) {
inT32 key) {
if (!list.empty ()) {
for (it.mark_cycle_pt (); !it.cycled_list (); it.forward ()) {
if (it.data ()->address == key) {
@ -73,7 +73,7 @@ void SORTED_FLOATS::remove( //remove the entry
float
SORTED_FLOATS::operator[] ( //get an entry
INT32 index //to list
inT32 index //to list
) {
it.move_to_first ();
return it.data_relative (index)->entry;

View File

@ -29,17 +29,17 @@ class SORTED_FLOAT:public ELIST_LINK
friend class SORTED_FLOATS;
public:
SORTED_FLOAT() {
SORTED_FLOAT() {
} //empty constructor
SORTED_FLOAT( //create one
float value, //value of entry
INT32 key) { //reference
inT32 key) { //reference
entry = value;
address = key;
}
private:
float entry; //value of float
INT32 address; //key
inT32 address; //key
};
ELISTIZEH (SORTED_FLOAT)
@ -51,11 +51,11 @@ class SORTED_FLOATS
}
void add( //add sample
float value, //sample float
INT32 key); //retrieval key
inT32 key); //retrieval key
void remove( //delete sample
INT32 key); //key to delete
inT32 key); //key to delete
float operator[] ( //index to list
INT32 index); //item to get
inT32 index); //item to get
private:
SORTED_FLOAT_LIST list; //list of floats

View File

@ -35,8 +35,8 @@ BOOL8 make_blocks_from_rows( //make thresholds
ROW *convert_row( //convert a row
TEXTROW *tessrow, //row to convert
BOOL8 do_shift, //true do do shift
INT16 &top, //top of row
INT16 &bottom //bottom of row
inT16 &top, //top of row
inT16 &bottom //bottom of row
);
void convert_words( //convert a row
TEXTROW *tessrow, //row to convert
@ -60,10 +60,10 @@ void accumulate_word_stats( //get stats
ICOORD &tright);
void blob_bounding_box( //get bounding box
TBLOB *blob, //blob to do
INT16 &xmin, //bounding box
INT16 &ymin,
INT16 &xmax, //of blob
INT16 &ymax);
inT16 &xmin, //bounding box
inT16 &ymin,
inT16 &xmax, //of blob
inT16 &ymax);
void free_blob( //free tess blob
TBLOB *blob //blob to free
);

View File

@ -150,11 +150,11 @@ void fix_row_pitch( //get some value
TO_ROW *bad_row, //row to fix
TO_BLOCK *bad_block, //block of bad_row
TO_BLOCK_LIST *blocks, //blocks to scan
INT32 row_target, //number of row
INT32 block_target //number of block
inT32 row_target, //number of row
inT32 block_target //number of block
) {
const char *res_string; //decision on line
INT16 mid_cuts;
inT16 mid_cuts;
int block_votes; //votes in block
int like_votes; //votes over page
int other_votes; //votes of unlike blocks
@ -170,7 +170,7 @@ void fix_row_pitch( //get some value
STATS like_stats; //pitches in page
block_votes = like_votes = other_votes = 0;
maxwidth = (INT32) ceil (bad_row->xheight * textord_words_maxspace);
maxwidth = (inT32) ceil (bad_row->xheight * textord_words_maxspace);
if (bad_row->pitch_decision != PITCH_DEF_FIXED
&& bad_row->pitch_decision != PITCH_DEF_PROP) {
block_stats.set_range (0, maxwidth);
@ -200,13 +200,13 @@ void fix_row_pitch( //get some value
if (block_index == block_target) {
if (row->pitch_decision == PITCH_DEF_FIXED) {
block_votes += textord_words_veto_power;
block_stats.add ((INT32) row->fixed_pitch,
block_stats.add ((inT32) row->fixed_pitch,
textord_words_veto_power);
}
else if (row->pitch_decision == PITCH_MAYBE_FIXED
|| row->pitch_decision == PITCH_CORR_FIXED) {
block_votes++;
block_stats.add ((INT32) row->fixed_pitch, 1);
block_stats.add ((inT32) row->fixed_pitch, 1);
}
else if (row->pitch_decision == PITCH_DEF_PROP)
block_votes -= textord_words_veto_power;
@ -217,13 +217,13 @@ void fix_row_pitch( //get some value
else {
if (row->pitch_decision == PITCH_DEF_FIXED) {
like_votes += textord_words_veto_power;
like_stats.add ((INT32) row->fixed_pitch,
like_stats.add ((inT32) row->fixed_pitch,
textord_words_veto_power);
}
else if (row->pitch_decision == PITCH_MAYBE_FIXED
|| row->pitch_decision == PITCH_CORR_FIXED) {
like_votes++;
like_stats.add ((INT32) row->fixed_pitch, 1);
like_stats.add ((inT32) row->fixed_pitch, 1);
}
else if (row->pitch_decision == PITCH_DEF_PROP)
like_votes -= textord_words_veto_power;
@ -309,8 +309,8 @@ void fix_row_pitch( //get some value
if (bad_row->fixed_pitch < textord_min_xheight)
bad_row->fixed_pitch = (float) textord_min_xheight;
bad_row->kern_size = bad_row->fixed_pitch / 4;
bad_row->min_space = (INT32) (bad_row->fixed_pitch * 0.6);
bad_row->max_nonspace = (INT32) (bad_row->fixed_pitch * 0.4);
bad_row->min_space = (inT32) (bad_row->fixed_pitch * 0.6);
bad_row->max_nonspace = (inT32) (bad_row->fixed_pitch * 0.4);
bad_row->space_threshold =
(bad_row->min_space + bad_row->max_nonspace) / 2;
bad_row->space_size = bad_row->fixed_pitch;
@ -338,10 +338,10 @@ void fix_row_pitch( //get some value
void compute_block_pitch( //process each block
TO_BLOCK *block, //input list
FCOORD rotation, //for drawing
INT32 block_index, //block number
inT32 block_index, //block number
BOOL8 testing_on //correct orientation
) {
BOX block_box; //bounding box
TBOX block_box; //bounding box
block_box = block->block->bounding_box ();
if (testing_on && textord_debug_pitch_test) {
@ -350,9 +350,9 @@ void compute_block_pitch( //process each block
block_box.left (), block_box.bottom (),
block_box.right (), block_box.top ());
}
block->min_space = (INT32) floor (block->xheight
block->min_space = (inT32) floor (block->xheight
* textord_words_default_minspace);
block->max_nonspace = (INT32) ceil (block->xheight
block->max_nonspace = (inT32) ceil (block->xheight
* textord_words_default_nonspace);
block->fixed_pitch = 0.0f;
block->space_size = (float) block->min_space;
@ -383,12 +383,12 @@ void compute_block_pitch( //process each block
BOOL8 compute_rows_pitch( //find line stats
TO_BLOCK *block, //block to do
INT32 block_index, //block number
inT32 block_index, //block number
BOOL8 testing_on //correct orientation
) {
INT32 maxwidth; //of spaces
inT32 maxwidth; //of spaces
TO_ROW *row; //current row
INT32 row_index; //row number.
inT32 row_index; //row number.
float lower, upper; //cluster thresholds
TO_ROW_IT row_it = block->get_rows ();
@ -397,7 +397,7 @@ BOOL8 compute_rows_pitch( //find line stats
row = row_it.data ();
ASSERT_HOST (row->xheight > 0);
row->compute_vertical_projection ();
maxwidth = (INT32) ceil (row->xheight * textord_words_maxspace);
maxwidth = (inT32) ceil (row->xheight * textord_words_maxspace);
if (row_pitch_stats (row, maxwidth, testing_on)
&& find_row_pitch (row, maxwidth,
textord_dotmatrix_gap + 1, block, block_index,
@ -430,8 +430,8 @@ BOOL8 try_doc_fixed( //determine pitch
TO_BLOCK_LIST *port_blocks, //input list
float gradient //page skew
) {
INT16 master_x; //uniform shifts
INT16 pitch; //median pitch.
inT16 master_x; //uniform shifts
inT16 pitch; //median pitch.
int x; //profile coord
int prop_blocks; //correct counts
int fixed_blocks;
@ -441,10 +441,10 @@ BOOL8 try_doc_fixed( //determine pitch
TO_BLOCK *block; //current block;
TO_ROW_IT row_it; //row iterator
TO_ROW *row; //current row
INT16 projection_left; //edges
INT16 projection_right;
INT16 row_left; //edges of row
INT16 row_right;
inT16 projection_left; //edges
inT16 projection_right;
inT16 row_left; //edges of row
inT16 row_right;
ICOORDELT_LIST *master_cells; //cells for page
float master_y; //uniform shifts
float shift_factor; //page skew correction
@ -455,7 +455,7 @@ BOOL8 try_doc_fixed( //determine pitch
STATS pitches (0, MAX_ALLOWED_PITCH);
//for median
float sp_sd; //space sd
INT16 mid_cuts; //no of cheap cuts
inT16 mid_cuts; //no of cheap cuts
float pitch_sd; //sync rating
if (block_it.empty ()
@ -486,14 +486,14 @@ BOOL8 try_doc_fixed( //determine pitch
row = row_it.data ();
total_row_count++;
if (row->fixed_pitch > 0)
pitches.add ((INT32) (row->fixed_pitch), 1);
pitches.add ((inT32) (row->fixed_pitch), 1);
//find median
row_y = row->baseline.y (master_x);
row_left =
(INT16) (row->projection_left -
(inT16) (row->projection_left -
shift_factor * (master_y - row_y));
row_right =
(INT16) (row->projection_right -
(inT16) (row->projection_right -
shift_factor * (master_y - row_y));
if (row_left < projection_left)
projection_left = row_left;
@ -513,7 +513,7 @@ BOOL8 try_doc_fixed( //determine pitch
row = row_it.data ();
row_y = row->baseline.y (master_x);
row_left =
(INT16) (row->projection_left -
(inT16) (row->projection_left -
shift_factor * (master_y - row_y));
for (x = row->projection_left; x < row->projection_right;
x++, row_left++) {
@ -530,7 +530,7 @@ BOOL8 try_doc_fixed( //determine pitch
row->intercept (), 1.0f, -1.0f, ScrollView::CORAL);
#endif
final_pitch = pitches.ile (0.5);
pitch = (INT16) final_pitch;
pitch = (inT16) final_pitch;
pitch_sd =
tune_row_pitch (row, &projection, projection_left, projection_right,
pitch * 0.75, final_pitch, sp_sd, mid_cuts,
@ -573,7 +573,7 @@ BOOL8 try_doc_fixed( //determine pitch
BOOL8 try_block_fixed( //find line stats
TO_BLOCK *block, //block to do
INT32 block_index //block number
inT32 block_index //block number
) {
return FALSE;
}
@ -587,19 +587,19 @@ BOOL8 try_block_fixed( //find line stats
BOOL8 try_rows_fixed( //find line stats
TO_BLOCK *block, //block to do
INT32 block_index, //block number
inT32 block_index, //block number
BOOL8 testing_on //correct orientation
) {
INT32 maxwidth; //of spaces
inT32 maxwidth; //of spaces
TO_ROW *row; //current row
INT32 row_index; //row number.
INT32 def_fixed = 0; //counters
INT32 def_prop = 0;
INT32 maybe_fixed = 0;
INT32 maybe_prop = 0;
INT32 dunno = 0;
INT32 corr_fixed = 0;
INT32 corr_prop = 0;
inT32 row_index; //row number.
inT32 def_fixed = 0; //counters
inT32 def_prop = 0;
inT32 maybe_fixed = 0;
inT32 maybe_prop = 0;
inT32 dunno = 0;
inT32 corr_fixed = 0;
inT32 corr_prop = 0;
float lower, upper; //cluster thresholds
TO_ROW_IT row_it = block->get_rows ();
@ -607,7 +607,7 @@ BOOL8 try_rows_fixed( //find line stats
for (row_it.mark_cycle_pt (); !row_it.cycled_list (); row_it.forward ()) {
row = row_it.data ();
ASSERT_HOST (row->xheight > 0);
maxwidth = (INT32) ceil (row->xheight * textord_words_maxspace);
maxwidth = (inT32) ceil (row->xheight * textord_words_maxspace);
if (row->fixed_pitch > 0 && fixed_pitch_row (row, block_index)) {
if (row->fixed_pitch == 0) {
lower = row->pr_nonsp;
@ -656,15 +656,15 @@ BOOL8 try_rows_fixed( //find line stats
void print_block_counts( //find line stats
TO_BLOCK *block, //block to do
INT32 block_index //block number
inT32 block_index //block number
) {
INT32 def_fixed = 0; //counters
INT32 def_prop = 0;
INT32 maybe_fixed = 0;
INT32 maybe_prop = 0;
INT32 dunno = 0;
INT32 corr_fixed = 0;
INT32 corr_prop = 0;
inT32 def_fixed = 0; //counters
inT32 def_prop = 0;
inT32 maybe_fixed = 0;
inT32 maybe_prop = 0;
inT32 dunno = 0;
inT32 corr_fixed = 0;
inT32 corr_prop = 0;
count_block_votes(block,
def_fixed,
@ -701,13 +701,13 @@ void print_block_counts( //find line stats
void count_block_votes( //find line stats
TO_BLOCK *block, //block to do
INT32 &def_fixed, //add to counts
INT32 &def_prop,
INT32 &maybe_fixed,
INT32 &maybe_prop,
INT32 &corr_fixed,
INT32 &corr_prop,
INT32 &dunno) {
inT32 &def_fixed, //add to counts
inT32 &def_prop,
inT32 &maybe_fixed,
inT32 &maybe_prop,
inT32 &corr_fixed,
inT32 &corr_prop,
inT32 &dunno) {
TO_ROW *row; //current row
TO_ROW_IT row_it = block->get_rows ();
@ -748,16 +748,16 @@ void count_block_votes( //find line stats
BOOL8 row_pitch_stats( //find line stats
TO_ROW *row, //current row
INT32 maxwidth, //of spaces
inT32 maxwidth, //of spaces
BOOL8 testing_on //correct orientation
) {
BLOBNBOX *blob; //current blob
int gap_index; //current gap
INT32 prev_x; //end of prev blob
INT32 cluster_count; //no of clusters
INT32 prev_count; //of clusters
INT32 smooth_factor; //for smoothing stats
BOX blob_box; //bounding box
inT32 prev_x; //end of prev blob
inT32 cluster_count; //no of clusters
inT32 prev_count; //of clusters
inT32 smooth_factor; //for smoothing stats
TBOX blob_box; //bounding box
float lower, upper; //cluster thresholds
//gap sizes
float gaps[BLOCK_STATS_CLUSTERS];
@ -768,7 +768,7 @@ BOOL8 row_pitch_stats( //find line stats
//clusters
smooth_factor =
(INT32) (row->xheight * textord_wordstats_smooth_factor + 1.5);
(inT32) (row->xheight * textord_wordstats_smooth_factor + 1.5);
if (!blob_it.empty ()) {
prev_x = blob_it.data ()->bounding_box ().right ();
blob_it.forward ();
@ -881,11 +881,11 @@ BOOL8 row_pitch_stats( //find line stats
BOOL8 find_row_pitch( //find lines
TO_ROW *row, //row to do
INT32 maxwidth, //max permitted space
INT32 dm_gap, //ignorable gaps
inT32 maxwidth, //max permitted space
inT32 dm_gap, //ignorable gaps
TO_BLOCK *block, //block of row
INT32 block_index, //block_number
INT32 row_index, //number of row
inT32 block_index, //block_number
inT32 row_index, //number of row
BOOL8 testing_on //correct orientation
) {
BOOL8 used_dm_model; //looks lik dot matrix
@ -1003,9 +1003,9 @@ BOOL8 find_row_pitch( //find lines
row->pitch_decision = PITCH_MAYBE_PROP;
row->fixed_pitch = pitch;
row->kern_size = gap_stats.ile (0.5);
row->min_space = (INT32) (row->fixed_pitch + non_space) / 2;
row->min_space = (inT32) (row->fixed_pitch + non_space) / 2;
if (row->min_space > row->fixed_pitch)
row->min_space = (INT32) row->fixed_pitch;
row->min_space = (inT32) row->fixed_pitch;
row->max_nonspace = row->min_space;
row->space_size = row->fixed_pitch;
row->space_threshold = (row->max_nonspace + row->min_space) / 2;
@ -1024,10 +1024,10 @@ BOOL8 find_row_pitch( //find lines
BOOL8 fixed_pitch_row( //find lines
TO_ROW *row, //row to do
INT32 block_index //block_number
inT32 block_index //block_number
) {
const char *res_string; //pitch result
INT16 mid_cuts; //no of cheap cuts
inT16 mid_cuts; //no of cheap cuts
float non_space; //gap size
float pitch_sd; //error on pitch
float sp_sd; //space sd
@ -1112,20 +1112,20 @@ BOOL8 count_pitch_stats( //find lines
float min_space, //estimate space size
BOOL8 ignore_outsize, //discard big objects
BOOL8 split_outsize, //split big objects
INT32 dm_gap //ignorable gaps
inT32 dm_gap //ignorable gaps
) {
BOOL8 prev_valid; //not word broken
BLOBNBOX *blob; //current blob
//blobs
BLOBNBOX_IT blob_it = row->blob_list ();
INT32 prev_right; //end of prev blob
INT32 prev_centre; //centre of previous blob
INT32 x_centre; //centre of this blob
INT32 blob_width; //width of blob
INT32 width_units; //no of widths in blob
inT32 prev_right; //end of prev blob
inT32 prev_centre; //centre of previous blob
inT32 x_centre; //centre of this blob
inT32 blob_width; //width of blob
inT32 width_units; //no of widths in blob
float width; //blob width
BOX blob_box; //bounding box
BOX joined_box; //of super blob
TBOX blob_box; //bounding box
TBOX joined_box; //of super blob
gap_stats->clear ();
pitch_stats->clear ();
@ -1148,7 +1148,7 @@ BOOL8 count_pitch_stats( //find lines
blob_width = joined_box.width ();
if (split_outsize) {
width_units =
(INT32) floor ((float) blob_width / initial_pitch + 0.5);
(inT32) floor ((float) blob_width / initial_pitch + 0.5);
if (width_units < 1)
width_units = 1;
width_units--;
@ -1160,7 +1160,7 @@ BOOL8 count_pitch_stats( //find lines
}
else
width_units = 0; //everything in
x_centre = (INT32) (joined_box.left ()
x_centre = (inT32) (joined_box.left ()
+ (blob_width -
width_units * initial_pitch) / 2);
if (prev_valid && width_units >= 0) {
@ -1172,7 +1172,7 @@ BOOL8 count_pitch_stats( //find lines
gap_stats->add (joined_box.left () - prev_right, 1);
pitch_stats->add (x_centre - prev_centre, 1);
}
prev_centre = (INT32) (x_centre + width_units * initial_pitch);
prev_centre = (inT32) (x_centre + width_units * initial_pitch);
prev_right = joined_box.right ();
prev_valid = blob_box.left () - joined_box.right () < min_space;
prev_valid = prev_valid && width_units >= 0;
@ -1195,17 +1195,17 @@ BOOL8 count_pitch_stats( //find lines
float tune_row_pitch( //find fp cells
TO_ROW *row, //row to do
STATS *projection, //vertical projection
INT16 projection_left, //edge of projection
INT16 projection_right, //edge of projection
inT16 projection_left, //edge of projection
inT16 projection_right, //edge of projection
float space_size, //size of blank
float &initial_pitch, //guess at pitch
float &best_sp_sd, //space sd
INT16 &best_mid_cuts, //no of cheap cuts
inT16 &best_mid_cuts, //no of cheap cuts
ICOORDELT_LIST *best_cells, //row cells
BOOL8 testing_on //inidividual words
) {
int pitch_delta; //offset pitch
INT16 mid_cuts; //cheap cuts
inT16 mid_cuts; //cheap cuts
float pitch_sd; //current sd
float best_sd; //best result
float best_pitch; //pitch for best result
@ -1307,23 +1307,23 @@ float tune_row_pitch( //find fp cells
float tune_row_pitch2( //find fp cells
TO_ROW *row, //row to do
STATS *projection, //vertical projection
INT16 projection_left, //edge of projection
INT16 projection_right, //edge of projection
inT16 projection_left, //edge of projection
inT16 projection_right, //edge of projection
float space_size, //size of blank
float &initial_pitch, //guess at pitch
float &best_sp_sd, //space sd
INT16 &best_mid_cuts, //no of cheap cuts
inT16 &best_mid_cuts, //no of cheap cuts
ICOORDELT_LIST *best_cells, //row cells
BOOL8 testing_on //inidividual words
) {
int pitch_delta; //offset pitch
INT16 pixel; //pixel coord
INT16 best_pixel; //pixel coord
INT16 best_delta; //best pitch
INT16 best_pitch; //best pitch
INT16 start; //of good range
INT16 end; //of good range
INT32 best_count; //lowest sum
inT16 pixel; //pixel coord
inT16 best_pixel; //pixel coord
inT16 best_delta; //best pitch
inT16 best_pitch; //best pitch
inT16 start; //of good range
inT16 end; //of good range
inT32 best_count; //lowest sum
float best_sd; //best result
STATS *sum_proj; //summed projection
@ -1335,7 +1335,7 @@ float tune_row_pitch2( //find fp cells
sum_proj = new STATS[textord_pitch_range * 2 + 1];
if (sum_proj == NULL)
return initial_pitch;
best_pitch = (INT32) initial_pitch;
best_pitch = (inT32) initial_pitch;
for (pitch_delta = -textord_pitch_range; pitch_delta <= textord_pitch_range;
pitch_delta++)
@ -1424,32 +1424,32 @@ float tune_row_pitch2( //find fp cells
float compute_pitch_sd( //find fp cells
TO_ROW *row, //row to do
STATS *projection, //vertical projection
INT16 projection_left, //edge
INT16 projection_right, //edge
inT16 projection_left, //edge
inT16 projection_right, //edge
float space_size, //size of blank
float initial_pitch, //guess at pitch
float &sp_sd, //space sd
INT16 &mid_cuts, //no of free cuts
inT16 &mid_cuts, //no of free cuts
ICOORDELT_LIST *row_cells, //list of chop pts
BOOL8 testing_on, //inidividual words
INT16 start, //start of good range
INT16 end //end of good range
inT16 start, //start of good range
inT16 end //end of good range
) {
INT16 occupation; //no of cells in word.
inT16 occupation; //no of cells in word.
//blobs
BLOBNBOX_IT blob_it = row->blob_list ();
BLOBNBOX_IT start_it; //start of word
BLOBNBOX_IT plot_it; //for plotting
INT16 blob_count; //no of blobs
BOX blob_box; //bounding box
BOX prev_box; //of super blob
INT32 prev_right; //of word sync
inT16 blob_count; //no of blobs
TBOX blob_box; //bounding box
TBOX prev_box; //of super blob
inT32 prev_right; //of word sync
int scale_factor; //on scores for big words
INT32 sp_count; //spaces
inT32 sp_count; //spaces
FPSEGPT_LIST seg_list; //char cells
FPSEGPT_IT seg_it; //iterator
INT16 segpos; //position of segment
INT16 cellpos; //previous cell boundary
inT16 segpos; //position of segment
inT16 cellpos; //previous cell boundary
//iterator
ICOORDELT_IT cell_it = row_cells;
ICOORDELT *cell; //new cell
@ -1457,7 +1457,7 @@ float compute_pitch_sd( //find fp cells
double spsum; //of spaces
double sp_var; //space error
double word_sync; //result for word
INT32 total_count; //total blobs
inT32 total_count; //total blobs
if ((pitsync_linear_version & 3) > 1) {
word_sync = compute_pitch_sd2 (row, projection, projection_left,
@ -1500,13 +1500,13 @@ float compute_pitch_sd( //find fp cells
plot_it = start_it;
if (pitsync_linear_version & 3)
word_sync =
check_pitch_sync2 (&start_it, blob_count, (INT16) initial_pitch, 2,
check_pitch_sync2 (&start_it, blob_count, (inT16) initial_pitch, 2,
projection, projection_left, projection_right,
row->xheight * textord_projection_scale,
occupation, &seg_list, start, end);
else
word_sync =
check_pitch_sync (&start_it, blob_count, (INT16) initial_pitch, 2,
check_pitch_sync (&start_it, blob_count, (inT16) initial_pitch, 2,
projection, &seg_list);
if (testing_on) {
tprintf ("Word ending at (%d,%d), len=%d, sync rating=%g, ",
@ -1542,9 +1542,9 @@ float compute_pitch_sd( //find fp cells
if (cell_it.empty () || segpos > cellpos + initial_pitch / 2) {
//big gap
while (!cell_it.empty () && segpos > cellpos + initial_pitch * 3 / 2) {
cell = new ICOORDELT (cellpos + (INT16) initial_pitch, 0);
cell = new ICOORDELT (cellpos + (inT16) initial_pitch, 0);
cell_it.add_after_then_move (cell);
cellpos += (INT16) initial_pitch;
cellpos += (inT16) initial_pitch;
}
//make new one
cell = new ICOORDELT (segpos, 0);
@ -1587,24 +1587,24 @@ float compute_pitch_sd( //find fp cells
float compute_pitch_sd2( //find fp cells
TO_ROW *row, //row to do
STATS *projection, //vertical projection
INT16 projection_left, //edge
INT16 projection_right, //edge
inT16 projection_left, //edge
inT16 projection_right, //edge
float initial_pitch, //guess at pitch
INT16 &occupation, //no of occupied cells
INT16 &mid_cuts, //no of free cuts
inT16 &occupation, //no of occupied cells
inT16 &mid_cuts, //no of free cuts
ICOORDELT_LIST *row_cells, //list of chop pts
BOOL8 testing_on, //inidividual words
INT16 start, //start of good range
INT16 end //end of good range
inT16 start, //start of good range
inT16 end //end of good range
) {
//blobs
BLOBNBOX_IT blob_it = row->blob_list ();
BLOBNBOX_IT plot_it;
INT16 blob_count; //no of blobs
BOX blob_box; //bounding box
inT16 blob_count; //no of blobs
TBOX blob_box; //bounding box
FPSEGPT_LIST seg_list; //char cells
FPSEGPT_IT seg_it; //iterator
INT16 segpos; //position of segment
inT16 segpos; //position of segment
//iterator
ICOORDELT_IT cell_it = row_cells;
ICOORDELT *cell; //new cell
@ -1630,7 +1630,7 @@ float compute_pitch_sd2( //find fp cells
}
while (!blob_it.cycled_list ());
plot_it = blob_it;
word_sync = check_pitch_sync2 (&blob_it, blob_count, (INT16) initial_pitch,
word_sync = check_pitch_sync2 (&blob_it, blob_count, (inT16) initial_pitch,
2, projection, projection_left,
projection_right,
row->xheight * textord_projection_scale,
@ -1679,25 +1679,25 @@ float compute_pitch_sd2( //find fp cells
void print_pitch_sd( //find fp cells
TO_ROW *row, //row to do
STATS *projection, //vertical projection
INT16 projection_left, //edges //size of blank
INT16 projection_right,
inT16 projection_left, //edges //size of blank
inT16 projection_right,
float space_size,
float initial_pitch //guess at pitch
) {
const char *res2; //pitch result
INT16 occupation; //used cells
inT16 occupation; //used cells
float sp_sd; //space sd
//blobs
BLOBNBOX_IT blob_it = row->blob_list ();
BLOBNBOX_IT start_it; //start of word
BLOBNBOX_IT row_start; //start of row
INT16 blob_count; //no of blobs
INT16 total_blob_count; //total blobs in line
BOX blob_box; //bounding box
BOX prev_box; //of super blob
INT32 prev_right; //of word sync
inT16 blob_count; //no of blobs
inT16 total_blob_count; //total blobs in line
TBOX blob_box; //bounding box
TBOX prev_box; //of super blob
inT32 prev_right; //of word sync
int scale_factor; //on scores for big words
INT32 sp_count; //spaces
inT32 sp_count; //spaces
FPSEGPT_LIST seg_list; //char cells
FPSEGPT_IT seg_it; //iterator
double sqsum; //sum of squares
@ -1732,7 +1732,7 @@ void print_pitch_sd( //find fp cells
while (!blob_it.cycled_list ()
&& blob_box.left () - prev_box.right () < space_size);
word_sync =
check_pitch_sync2 (&start_it, blob_count, (INT16) initial_pitch, 2,
check_pitch_sync2 (&start_it, blob_count, (inT16) initial_pitch, 2,
projection, projection_left, projection_right,
row->xheight * textord_projection_scale,
occupation, &seg_list, 0, 0);
@ -1769,7 +1769,7 @@ void print_pitch_sd( //find fp cells
start_it = row_start;
blob_it = row_start;
word_sync =
check_pitch_sync2 (&blob_it, total_blob_count, (INT16) initial_pitch, 2,
check_pitch_sync2 (&blob_it, total_blob_count, (inT16) initial_pitch, 2,
projection, projection_left, projection_right,
row->xheight * textord_projection_scale, occupation,
&seg_list, 0, 0);
@ -1841,18 +1841,18 @@ void find_repeated_chars( //search for equal chars
BLOBNBOX *nextblob; //neighbour to compare
BLOBNBOX_IT box_it; //iterator
BLOBNBOX_IT search_it; //forward search
INT32 blobcount; //no of neighbours
INT32 matched_blobcount; //no of matches
INT32 blobindex; //in row
INT32 row_length; //blobs in row
INT32 width_change; //max width change
INT32 blob_width; //required blob width
INT32 space_width; //required gap width
INT32 prev_right; //right edge of last blob
inT32 blobcount; //no of neighbours
inT32 matched_blobcount; //no of matches
inT32 blobindex; //in row
inT32 row_length; //blobs in row
inT32 width_change; //max width change
inT32 blob_width; //required blob width
inT32 space_width; //required gap width
inT32 prev_right; //right edge of last blob
float rating; //match rating
PBLOB *pblob1; //polygonal blob
PBLOB *pblob2; //second blob
BOX word_box; //for plotting
TBOX word_box; //for plotting
if (row_it.empty ())
return; //empty block
@ -1865,8 +1865,8 @@ void find_repeated_chars( //search for equal chars
bol = TRUE;
if (!box_it.empty ()) {
real_row = new ROW (row,
(INT16) block->kern_size,
(INT16) block->space_size);
(inT16) block->kern_size,
(inT16) block->space_size);
do {
bblob = box_it.data ();
blobcount = 1;
@ -1900,7 +1900,7 @@ void find_repeated_chars( //search for equal chars
blob_width >
space_width ? blob_width : space_width;
width_change =
(INT32) (width_change *
(inT32) (width_change *
textord_repch_width_variance);
if (width_change < 3)
width_change = 3;
@ -1968,7 +1968,7 @@ void find_repeated_chars( //search for equal chars
word_box.bottom (), word_box.right (),
word_box.top ());
//perimeter_color_index(to_win, RED);
to_win->Pen(255,0,0);
to_win->Pen(255,0,0);
//interior_style(to_win, INT_HOLLOW, TRUE);
to_win->Rectangle(word_box.left (),
word_box.bottom (), word_box.right (),
@ -2010,10 +2010,10 @@ void plot_fp_word( //draw block of words
for (row_it.mark_cycle_pt (); !row_it.cycled_list (); row_it.forward ()) {
row = row_it.data ();
row->min_space = (INT32) ((pitch + nonspace) / 2);
row->min_space = (inT32) ((pitch + nonspace) / 2);
row->max_nonspace = row->min_space;
row->space_threshold = row->min_space;
plot_word_decisions (to_win, (INT16) pitch, row);
plot_word_decisions (to_win, (inT16) pitch, row);
}
}
#endif

View File

@ -52,18 +52,18 @@ void fix_row_pitch( //get some value
TO_ROW *bad_row, //row to fix
TO_BLOCK *bad_block, //block of bad_row
TO_BLOCK_LIST *blocks, //blocks to scan
INT32 row_target, //number of row
INT32 block_target //number of block
inT32 row_target, //number of row
inT32 block_target //number of block
);
void compute_block_pitch( //process each block
TO_BLOCK *block, //input list
FCOORD rotation, //for drawing
INT32 block_index, //block number
inT32 block_index, //block number
BOOL8 testing_on //correct orientation
);
BOOL8 compute_rows_pitch( //find line stats
TO_BLOCK *block, //block to do
INT32 block_index, //block number
inT32 block_index, //block number
BOOL8 testing_on //correct orientation
);
BOOL8 try_doc_fixed( //determine pitch
@ -73,43 +73,43 @@ BOOL8 try_doc_fixed( //determine pitch
);
BOOL8 try_block_fixed( //find line stats
TO_BLOCK *block, //block to do
INT32 block_index //block number
inT32 block_index //block number
);
BOOL8 try_rows_fixed( //find line stats
TO_BLOCK *block, //block to do
INT32 block_index, //block number
inT32 block_index, //block number
BOOL8 testing_on //correct orientation
);
void print_block_counts( //find line stats
TO_BLOCK *block, //block to do
INT32 block_index //block number
inT32 block_index //block number
);
void count_block_votes( //find line stats
TO_BLOCK *block, //block to do
INT32 &def_fixed, //add to counts
INT32 &def_prop,
INT32 &maybe_fixed,
INT32 &maybe_prop,
INT32 &corr_fixed,
INT32 &corr_prop,
INT32 &dunno);
inT32 &def_fixed, //add to counts
inT32 &def_prop,
inT32 &maybe_fixed,
inT32 &maybe_prop,
inT32 &corr_fixed,
inT32 &corr_prop,
inT32 &dunno);
BOOL8 row_pitch_stats( //find line stats
TO_ROW *row, //current row
INT32 maxwidth, //of spaces
inT32 maxwidth, //of spaces
BOOL8 testing_on //correct orientation
);
BOOL8 find_row_pitch( //find lines
TO_ROW *row, //row to do
INT32 maxwidth, //max permitted space
INT32 dm_gap, //ignorable gaps
inT32 maxwidth, //max permitted space
inT32 dm_gap, //ignorable gaps
TO_BLOCK *block, //block of row
INT32 block_index, //block_number
INT32 row_index, //number of row
inT32 block_index, //block_number
inT32 row_index, //number of row
BOOL8 testing_on //correct orientation
);
BOOL8 fixed_pitch_row( //find lines
TO_ROW *row, //row to do
INT32 block_index //block_number
inT32 block_index //block_number
);
BOOL8 count_pitch_stats( //find lines
TO_ROW *row, //row to do
@ -119,64 +119,64 @@ BOOL8 count_pitch_stats( //find lines
float min_space, //estimate space size
BOOL8 ignore_outsize, //discard big objects
BOOL8 split_outsize, //split big objects
INT32 dm_gap //ignorable gaps
inT32 dm_gap //ignorable gaps
);
float tune_row_pitch( //find fp cells
TO_ROW *row, //row to do
STATS *projection, //vertical projection
INT16 projection_left, //edge of projection
INT16 projection_right, //edge of projection
inT16 projection_left, //edge of projection
inT16 projection_right, //edge of projection
float space_size, //size of blank
float &initial_pitch, //guess at pitch
float &best_sp_sd, //space sd
INT16 &best_mid_cuts, //no of cheap cuts
inT16 &best_mid_cuts, //no of cheap cuts
ICOORDELT_LIST *best_cells, //row cells
BOOL8 testing_on //inidividual words
);
float tune_row_pitch2( //find fp cells
TO_ROW *row, //row to do
STATS *projection, //vertical projection
INT16 projection_left, //edge of projection
INT16 projection_right, //edge of projection
inT16 projection_left, //edge of projection
inT16 projection_right, //edge of projection
float space_size, //size of blank
float &initial_pitch, //guess at pitch
float &best_sp_sd, //space sd
INT16 &best_mid_cuts, //no of cheap cuts
inT16 &best_mid_cuts, //no of cheap cuts
ICOORDELT_LIST *best_cells, //row cells
BOOL8 testing_on //inidividual words
);
float compute_pitch_sd ( //find fp cells
TO_ROW * row, //row to do
STATS * projection, //vertical projection
INT16 projection_left, //edge
INT16 projection_right, //edge
inT16 projection_left, //edge
inT16 projection_right, //edge
float space_size, //size of blank
float initial_pitch, //guess at pitch
float &sp_sd, //space sd
INT16 & mid_cuts, //no of free cuts
inT16 & mid_cuts, //no of free cuts
ICOORDELT_LIST * row_cells, //list of chop pts
BOOL8 testing_on, //inidividual words
INT16 start = 0, //start of good range
INT16 end = 0 //end of good range
inT16 start = 0, //start of good range
inT16 end = 0 //end of good range
);
float compute_pitch_sd2 ( //find fp cells
TO_ROW * row, //row to do
STATS * projection, //vertical projection
INT16 projection_left, //edge
INT16 projection_right, //edge
inT16 projection_left, //edge
inT16 projection_right, //edge
float initial_pitch, //guess at pitch
INT16 & occupation, //no of occupied cells
INT16 & mid_cuts, //no of free cuts
inT16 & occupation, //no of occupied cells
inT16 & mid_cuts, //no of free cuts
ICOORDELT_LIST * row_cells, //list of chop pts
BOOL8 testing_on, //inidividual words
INT16 start = 0, //start of good range
INT16 end = 0 //end of good range
inT16 start = 0, //start of good range
inT16 end = 0 //end of good range
);
void print_pitch_sd( //find fp cells
TO_ROW *row, //row to do
STATS *projection, //vertical projection
INT16 projection_left, //edges //size of blank
INT16 projection_right,
inT16 projection_left, //edges //size of blank
inT16 projection_right,
float space_size,
float initial_pitch //guess at pitch
);

View File

@ -1,8 +1,8 @@
/**********************************************************************
* File: tordmain.cpp (Formerly textordp.c)
* Description: C++ top level textord code.
* Author: Ray Smith
* Created: Tue Jul 28 17:12:33 BST 1992
* Author: Ray Smith
* Created: Tue Jul 28 17:12:33 BST 1992
*
* (C) Copyright 1992, Hewlett-Packard Ltd.
** Licensed under the Apache License, Version 2.0 (the "License");
@ -114,7 +114,7 @@ void read_and_textord( //read .pb file
int c; //input character
FILE *infp; //input file
BLOCK *block; //current block
BOX page_box; //bounding_box
TBOX page_box; //bounding_box
BLOCK_IT block_it = blocks; //iterator
//different orientations
TO_BLOCK_LIST land_blocks, port_blocks;
@ -153,7 +153,7 @@ void edges_and_textord( //read .pb file
const char *lastdot; //of name
STRING name = filename; //truncated name
ICOORD page_tr;
BOX page_box; //bounding_box
TBOX page_box; //bounding_box
PDBLK_CLIST pd_blocks; //copy of list
BLOCK_IT block_it = blocks; //iterator
PDBLK_C_IT pd_it = &pd_blocks; //iterator
@ -355,8 +355,8 @@ float filter_noise_blobs( //separate noise
BLOBNBOX_LIST *small_list, //small blobs
BLOBNBOX_LIST *large_list //large blobs
) {
INT16 height; //height of blob
INT16 width; //of blob
inT16 height; //height of blob
inT16 width; //of blob
BLOBNBOX_IT src_it = src_list; //iterators
BLOBNBOX_IT noise_it = noise_list;
BLOBNBOX_IT small_it = small_list;
@ -403,8 +403,8 @@ float filter_noise_blobs2( //separate noise
BLOBNBOX_LIST *small_list, //small blobs
BLOBNBOX_LIST *large_list //large blobs
) {
INT16 height; //height of blob
INT16 width; //of blob
inT16 height; //height of blob
inT16 width; //of blob
BLOBNBOX *blob; //current blob
float initial_x; //first guess
BLOBNBOX_IT src_it = src_list; //iterators
@ -439,9 +439,11 @@ float filter_noise_blobs2( //separate noise
small_it.move_to_first ();
for (small_it.mark_cycle_pt (); !small_it.cycled_list ();
small_it.forward ()) {
height = small_it.data ()->bounding_box ().height ();
if (height >= min_y)
large_it.add_after_then_move (small_it.extract ());
height = small_it.data()->bounding_box().height();
if (height > max_y)
large_it.add_after_then_move(small_it.extract ());
else if (height >= min_y)
src_it.add_after_then_move(small_it.extract ());
}
size_stats.clear ();
for (src_it.mark_cycle_pt (); !src_it.cycled_list (); src_it.forward ()) {
@ -545,16 +547,16 @@ BOOL8 clean_noise_from_row( //remove empties
ROW *row //row to clean
) {
BOOL8 testing_on;
BOX blob_box; //bounding box
TBOX blob_box; //bounding box
C_BLOB *blob; //current blob
C_OUTLINE *outline; //current outline
WERD *word; //current word
INT32 blob_size; //biggest size
INT32 trans_count = 0; //no of transitions
INT32 trans_threshold; //noise tolerance
INT32 dot_count; //small objects
INT32 norm_count; //normal objects
INT32 super_norm_count; //real char-like
inT32 blob_size; //biggest size
inT32 trans_count = 0; //no of transitions
inT32 trans_threshold; //noise tolerance
inT32 dot_count; //small objects
inT32 norm_count; //normal objects
inT32 super_norm_count; //real char-like
//words of row
WERD_IT word_it = row->word_list ();
C_BLOB_IT blob_it; //blob iterator
@ -653,19 +655,19 @@ BOOL8 clean_noise_from_row( //remove empties
void clean_noise_from_words( //remove empties
ROW *row //row to clean
) {
BOX blob_box; //bounding box
INT8 *word_dud; //was it chucked
TBOX blob_box; //bounding box
inT8 *word_dud; //was it chucked
C_BLOB *blob; //current blob
C_OUTLINE *outline; //current outline
WERD *word; //current word
INT32 blob_size; //biggest size
INT32 trans_count; //no of transitions
INT32 trans_threshold; //noise tolerance
INT32 dot_count; //small objects
INT32 norm_count; //normal objects
INT32 dud_words; //number discarded
INT32 ok_words; //number remaining
INT32 word_index; //current word
inT32 blob_size; //biggest size
inT32 trans_count; //no of transitions
inT32 trans_threshold; //noise tolerance
inT32 dot_count; //small objects
inT32 norm_count; //normal objects
inT32 dud_words; //number discarded
inT32 ok_words; //number remaining
inT32 word_index; //current word
//words of row
WERD_IT word_it = row->word_list ();
C_BLOB_IT blob_it; //blob iterator
@ -674,7 +676,7 @@ void clean_noise_from_words( //remove empties
ok_words = word_it.length ();
if (ok_words == 0 || textord_no_rejects)
return;
word_dud = (INT8 *) alloc_mem (ok_words * sizeof (INT8));
word_dud = (inT8 *) alloc_mem (ok_words * sizeof (inT8));
dud_words = 0;
ok_words = 0;
word_index = 0;
@ -772,13 +774,13 @@ void clean_noise_from_words( //remove empties
void tweak_row_baseline( //remove empties
ROW *row //row to clean
) {
BOX blob_box; //bounding box
TBOX blob_box; //bounding box
C_BLOB *blob; //current blob
WERD *word; //current word
INT32 blob_count; //no of blobs
INT32 src_index; //source segment
INT32 dest_index; //destination segment
INT32 *xstarts; //spline segments
inT32 blob_count; //no of blobs
inT32 src_index; //source segment
inT32 dest_index; //destination segment
inT32 *xstarts; //spline segments
double *coeffs; //spline coeffs
float ydiff; //baseline error
float x_centre; //centre of blob
@ -795,8 +797,8 @@ void tweak_row_baseline( //remove empties
if (blob_count == 0)
return;
xstarts =
(INT32 *) alloc_mem ((blob_count + row->baseline.segments + 1) *
sizeof (INT32));
(inT32 *) alloc_mem ((blob_count + row->baseline.segments + 1) *
sizeof (inT32));
coeffs =
(double *) alloc_mem ((blob_count + row->baseline.segments) * 3 *
sizeof (double));
@ -884,7 +886,7 @@ void tweak_row_baseline( //remove empties
* Sort function to sort blobs in y from page top.
**********************************************************************/
INT32 blob_y_order( //sort function
inT32 blob_y_order( //sort function
void *item1, //items to compare
void *item2) {
//converted ptr

View File

@ -126,7 +126,7 @@ void clean_noise_from_words( //remove empties
void tweak_row_baseline( //remove empties
ROW *row //row to clean
);
INT32 blob_y_order( //sort function
inT32 blob_y_order( //sort function
void *item1, //items to compare
void *item2);
#endif

View File

@ -121,9 +121,9 @@ void to_spacing( //set spacing
TO_ROW *row; //current row
int block_index; //block number
int row_index; //row number
INT16 block_space_gap_width; //Estimated width of real spaces for whole block
inT16 block_space_gap_width; //Estimated width of real spaces for whole block
//Estimate width ofnon space gaps for whole block
INT16 block_non_space_gap_width;
inT16 block_non_space_gap_width;
//Old fixed/prop result
BOOL8 old_text_ord_proportional;
GAPMAP *gapmap = NULL; //map of big vert gaps in blk
@ -164,7 +164,7 @@ void to_spacing( //set spacing
}
#ifndef GRAPHICS_DISABLED
if (textord_show_initial_words)
plot_word_decisions (to_win, (INT16) row->fixed_pitch, row);
plot_word_decisions (to_win, (inT16) row->fixed_pitch, row);
#endif
row_index++;
}
@ -182,8 +182,8 @@ void block_spacing_stats( //DEBUG USE ONLY
TO_BLOCK *block,
GAPMAP *gapmap,
BOOL8 &old_text_ord_proportional,
INT16 &block_space_gap_width, //resulting estimate
INT16 &block_non_space_gap_width //resulting estimate
inT16 &block_space_gap_width, //resulting estimate
inT16 &block_non_space_gap_width //resulting estimate
) {
TO_ROW_IT row_it; //row iterator
TO_ROW *row; //current row
@ -193,16 +193,16 @@ void block_spacing_stats( //DEBUG USE ONLY
//DEBUG USE ONLY
STATS all_gap_stats (0, MAXSPACING);
STATS space_gap_stats (0, MAXSPACING);
INT16 minwidth = MAX_INT16; //narrowest blob
BOX blob_box;
BOX prev_blob_box;
INT16 centre_to_centre;
INT16 gap_width;
inT16 minwidth = MAX_INT16; //narrowest blob
TBOX blob_box;
TBOX prev_blob_box;
inT16 centre_to_centre;
inT16 gap_width;
float real_space_threshold;
float iqr_centre_to_centre; //DEBUG USE ONLY
float iqr_all_gap_stats; //DEBUG USE ONLY
INT32 end_of_row;
INT32 row_length;
inT32 end_of_row;
inT32 row_length;
row_it.set_to_list (block->get_rows ());
for (row_it.mark_cycle_pt (); !row_it.cycled_list (); row_it.forward ()) {
@ -275,7 +275,7 @@ void block_spacing_stats( //DEBUG USE ONLY
block. Do this by using a crude threshold to ignore "narrow" gaps, then
find the median of the "wide" gaps and use this.
*/
block_non_space_gap_width = (INT16) floor (all_gap_stats.median ());
block_non_space_gap_width = (inT16) floor (all_gap_stats.median ());
// median gap
row_it.set_to_list (block->get_rows ());
@ -340,7 +340,7 @@ void block_spacing_stats( //DEBUG USE ONLY
block_space_gap_width = -1;//No est. space width
else
block_space_gap_width =
MAX ((INT16) floor (space_gap_stats.median ()),
MAX ((inT16) floor (space_gap_stats.median ()),
3 * block_non_space_gap_width);
}
}
@ -355,10 +355,10 @@ void block_spacing_stats( //DEBUG USE ONLY
void row_spacing_stats( //estimate for block
TO_ROW *row,
GAPMAP *gapmap,
INT16 block_idx,
INT16 row_idx,
INT16 block_space_gap_width,
INT16 block_non_space_gap_width //estimate for block
inT16 block_idx,
inT16 row_idx,
inT16 block_space_gap_width,
inT16 block_non_space_gap_width //estimate for block
) {
//iterator
BLOBNBOX_IT blob_it = row->blob_list ();
@ -366,30 +366,30 @@ void row_spacing_stats( //estimate for block
STATS cert_space_gap_stats (0, MAXSPACING);
STATS all_space_gap_stats (0, MAXSPACING);
STATS small_gap_stats (0, MAXSPACING);
BOX blob_box;
BOX prev_blob_box;
INT16 gap_width;
INT16 real_space_threshold = 0;
INT16 max = 0;
INT16 index;
INT16 large_gap_count = 0;
TBOX blob_box;
TBOX prev_blob_box;
inT16 gap_width;
inT16 real_space_threshold = 0;
inT16 max = 0;
inT16 index;
inT16 large_gap_count = 0;
BOOL8 suspected_table;
INT32 max_max_nonspace; //upper bound
inT32 max_max_nonspace; //upper bound
BOOL8 good_block_space_estimate = block_space_gap_width > 0;
INT32 end_of_row;
INT32 row_length = 0;
inT32 end_of_row;
inT32 row_length = 0;
float sane_space;
INT32 sane_threshold;
inT32 sane_threshold;
/* Collect first pass stats for row */
if (!good_block_space_estimate)
block_space_gap_width = INT16 (floor (row->xheight / 2));
block_space_gap_width = inT16 (floor (row->xheight / 2));
if (!row->blob_list ()->empty ()) {
if (tosp_threshold_bias1 > 0)
real_space_threshold =
block_non_space_gap_width +
INT16 (floor (0.5 +
inT16 (floor (0.5 +
tosp_threshold_bias1 * (block_space_gap_width -
block_non_space_gap_width)));
else
@ -469,7 +469,7 @@ void row_spacing_stats( //estimate for block
else
row->kern_size = block_non_space_gap_width;
row->space_threshold =
INT32 (floor ((row->space_size + row->kern_size) / 2));
inT32 (floor ((row->space_size + row->kern_size) / 2));
}
else
old_to_method(row,
@ -494,7 +494,7 @@ void row_spacing_stats( //estimate for block
block_idx, row_idx,
row->kern_size, row->space_threshold, row->space_size);
row->space_threshold =
(INT32) (tosp_table_kn_sp_ratio * row->kern_size);
(inT32) (tosp_table_kn_sp_ratio * row->kern_size);
row->space_size = MAX (row->space_threshold + 1, row->xheight);
}
}
@ -518,10 +518,10 @@ void row_spacing_stats( //estimate for block
row->space_size, sane_space);
row->space_size = sane_space;
row->space_threshold =
INT32 (floor ((row->space_size + row->kern_size) / 2));
inT32 (floor ((row->space_size + row->kern_size) / 2));
}
/* NEVER let threshold get VERY far away from kern */
sane_threshold = INT32 (floor (tosp_max_sane_kn_thresh *
sane_threshold = inT32 (floor (tosp_max_sane_kn_thresh *
MAX (row->kern_size, 2.5)));
if (row->space_threshold > sane_threshold) {
if (tosp_debug_level > 0)
@ -537,7 +537,7 @@ void row_spacing_stats( //estimate for block
if (suspected_table) {
sane_space = MAX (tosp_table_kn_sp_ratio * row->kern_size,
tosp_table_xht_sp_ratio * row->xheight);
sane_threshold = INT32 (floor ((sane_space + row->kern_size) / 2));
sane_threshold = inT32 (floor ((sane_space + row->kern_size) / 2));
if ((row->space_size < sane_space) ||
(row->space_threshold < sane_threshold)) {
@ -547,7 +547,7 @@ void row_spacing_stats( //estimate for block
row->kern_size,
row->space_threshold, row->space_size);
//the minimum sane value
row->space_threshold = (INT32) sane_space;
row->space_threshold = (inT32) sane_space;
row->space_size = MAX (row->space_threshold + 1, row->xheight);
}
}
@ -565,8 +565,8 @@ void row_spacing_stats( //estimate for block
else {
/* Any gap greater than 0.6 x-ht is bound to be a space (isn't it:-) */
row->min_space =
MIN (INT32 (ceil (tosp_fuzzy_space_factor * row->xheight)),
INT32 (row->space_size));
MIN (inT32 (ceil (tosp_fuzzy_space_factor * row->xheight)),
inT32 (row->space_size));
if (row->min_space <= row->space_threshold)
//Dont be silly
row->min_space = row->space_threshold + 1;
@ -583,7 +583,7 @@ void row_spacing_stats( //estimate for block
below the threshold.
*/
max_max_nonspace = INT32 ((row->space_threshold + row->kern_size) / 2);
max_max_nonspace = inT32 ((row->space_threshold + row->kern_size) / 2);
//default
row->max_nonspace = max_max_nonspace;
@ -604,7 +604,7 @@ void row_spacing_stats( //estimate for block
if ((tosp_fuzzy_sp_fraction > 0) &&
(row->space_size > row->space_threshold))
row->min_space = MAX (row->min_space,
(INT32) ceil (row->space_threshold +
(inT32) ceil (row->space_threshold +
tosp_fuzzy_sp_fraction *
(row->space_size -
row->space_threshold)));
@ -619,11 +619,11 @@ void row_spacing_stats( //estimate for block
if ((tosp_table_fuzzy_kn_sp_ratio > 0) &&
(suspected_table || tosp_fuzzy_limit_all))
row->min_space = MAX (row->min_space,
(INT32) ceil (tosp_table_fuzzy_kn_sp_ratio *
(inT32) ceil (tosp_table_fuzzy_kn_sp_ratio *
row->kern_size));
if ((tosp_fuzzy_kn_fraction > 0) && (row->kern_size < row->space_threshold))
row->max_nonspace = (INT32) floor (0.5 + row->kern_size +
row->max_nonspace = (inT32) floor (0.5 + row->kern_size +
tosp_fuzzy_kn_fraction *
(row->space_threshold -
row->kern_size));
@ -647,8 +647,8 @@ void old_to_method( //estimate for block
STATS *all_gap_stats,
STATS *space_gap_stats,
STATS *small_gap_stats,
INT16 block_space_gap_width,
INT16 block_non_space_gap_width //estimate for block
inT16 block_space_gap_width,
inT16 block_non_space_gap_width //estimate for block
) {
/* Old to condition was > 2 */
if (space_gap_stats->get_total () >= tosp_enough_space_samples_for_median) {
@ -694,7 +694,7 @@ void old_to_method( //estimate for block
if (tosp_threshold_bias2 > 0)
row->space_threshold =
INT32 (floor (0.5 + row->kern_size +
inT32 (floor (0.5 + row->kern_size +
tosp_threshold_bias2 * (row->space_size -
row->kern_size)));
else
@ -707,7 +707,7 @@ void old_to_method( //estimate for block
and kern_size.)
*/
row->space_threshold =
INT32 (floor ((row->space_size + row->kern_size) / 2));
inT32 (floor ((row->space_size + row->kern_size) / 2));
}
@ -720,28 +720,28 @@ BOOL8 isolated_row_stats(TO_ROW *row,
GAPMAP *gapmap,
STATS *all_gap_stats,
BOOL8 suspected_table,
INT16 block_idx,
INT16 row_idx) {
inT16 block_idx,
inT16 row_idx) {
float kern_estimate;
float crude_threshold_estimate;
INT16 small_gaps_count;
INT16 total;
inT16 small_gaps_count;
inT16 total;
//iterator
BLOBNBOX_IT blob_it = row->blob_list ();
STATS cert_space_gap_stats (0, MAXSPACING);
STATS all_space_gap_stats (0, MAXSPACING);
STATS small_gap_stats (0, MAXSPACING);
BOX blob_box;
BOX prev_blob_box;
INT16 gap_width;
INT32 end_of_row;
INT32 row_length;
TBOX blob_box;
TBOX prev_blob_box;
inT16 gap_width;
inT32 end_of_row;
inT32 row_length;
kern_estimate = all_gap_stats->median ();
crude_threshold_estimate = MAX (tosp_init_guess_kn_mult * kern_estimate,
tosp_init_guess_xht_mult * row->xheight);
small_gaps_count = stats_count_under (all_gap_stats,
(INT16)
(inT16)
ceil (crude_threshold_estimate));
total = all_gap_stats->get_total ();
@ -809,7 +809,7 @@ BOOL8 isolated_row_stats(TO_ROW *row,
else
row->kern_size = all_gap_stats->median ();
row->space_threshold =
INT32 (floor ((row->space_size + row->kern_size) / 2));
inT32 (floor ((row->space_size + row->kern_size) / 2));
/* Sanity check */
if ((row->kern_size >= row->space_threshold) ||
(row->space_threshold >= row->space_size) ||
@ -832,9 +832,9 @@ BOOL8 isolated_row_stats(TO_ROW *row,
}
INT16 stats_count_under(STATS *stats, INT16 threshold) {
INT16 index;
INT16 total = 0;
inT16 stats_count_under(STATS *stats, inT16 threshold) {
inT16 index;
inT16 total = 0;
for (index = 0; index < threshold; index++)
total += stats->pile_count (index);
@ -861,10 +861,10 @@ INT16 stats_count_under(STATS *stats, INT16 threshold) {
void improve_row_threshold(TO_ROW *row, STATS *all_gap_stats) {
float sp = row->space_size;
float kn = row->kern_size;
INT16 reqd_zero_width = 0;
INT16 zero_width = 0;
INT16 zero_start = 0;
INT16 index = 0;
inT16 reqd_zero_width = 0;
inT16 zero_width = 0;
inT16 zero_start = 0;
inT16 index = 0;
if (tosp_debug_level > 10)
tprintf ("Improve row threshold 0");
@ -872,7 +872,7 @@ void improve_row_threshold(TO_ROW *row, STATS *all_gap_stats) {
(sp <= 10) ||
(sp <= 3 * kn) ||
(stats_count_under (all_gap_stats,
(INT16) ceil (kn + (sp - kn) / 3 + 0.5)) <
(inT16) ceil (kn + (sp - kn) / 3 + 0.5)) <
(0.75 * all_gap_stats->get_total ())))
return;
if (tosp_debug_level > 10)
@ -882,11 +882,11 @@ void improve_row_threshold(TO_ROW *row, STATS *all_gap_stats) {
max( 3, (sp - kn)/3 ) and starts between kn and sp. If found, and current
threshold is not within it, move the threshold so that is is just inside it.
*/
reqd_zero_width = (INT16) floor ((sp - kn) / 3 + 0.5);
reqd_zero_width = (inT16) floor ((sp - kn) / 3 + 0.5);
if (reqd_zero_width < 3)
reqd_zero_width = 3;
for (index = INT16 (ceil (kn)); index < INT16 (floor (sp)); index++) {
for (index = inT16 (ceil (kn)); index < inT16 (floor (sp)); index++) {
if (all_gap_stats->pile_count (index) == 0) {
if (zero_width == 0)
zero_start = index;
@ -942,10 +942,10 @@ ROW *make_prop_words( //find lines
the gap between the word being built and the next one. */
BOOL8 prev_fuzzy_sp; //probably space
BOOL8 prev_fuzzy_non; //probably not
UINT8 prev_blanks; //in front of word
uinT8 prev_blanks; //in front of word
BOOL8 fuzzy_sp; //probably space
BOOL8 fuzzy_non; //probably not
UINT8 blanks; //in front of word
uinT8 blanks; //in front of word
ROW *real_row; //output row
OUTLINE_IT out_it; //outlines
C_OUTLINE_IT cout_it;
@ -957,24 +957,24 @@ ROW *make_prop_words( //find lines
WERD_IT word_it; //new words
WERD *word; //new word
WERD_IT rep_char_it; //repeated char words
INT32 next_rep_char_word_right = MAX_INT32;
inT32 next_rep_char_word_right = MAX_INT32;
float repetition_spacing; //gap between repetitions
INT32 xstarts[2]; //row ends
inT32 xstarts[2]; //row ends
double coeffs[3]; //quadratic
INT32 prev_x; //end of prev blob
inT32 prev_x; //end of prev blob
BLOBNBOX *bblob; //current blob
BOX blob_box; //bounding box
TBOX blob_box; //bounding box
BLOBNBOX_IT box_it; //iterator
BOX prev_blob_box;
BOX next_blob_box;
INT16 prev_gap = MAX_INT16;
INT16 current_gap = MAX_INT16;
INT16 next_gap = MAX_INT16;
INT16 prev_within_xht_gap = MAX_INT16;
INT16 current_within_xht_gap = MAX_INT16;
INT16 next_within_xht_gap = MAX_INT16;
INT16 word_count = 0;
static INT16 row_count = 0;
TBOX prev_blob_box;
TBOX next_blob_box;
inT16 prev_gap = MAX_INT16;
inT16 current_gap = MAX_INT16;
inT16 next_gap = MAX_INT16;
inT16 prev_within_xht_gap = MAX_INT16;
inT16 current_within_xht_gap = MAX_INT16;
inT16 next_within_xht_gap = MAX_INT16;
inT16 word_count = 0;
static inT16 row_count = 0;
row_count++;
rep_char_it.set_to_list (&(row->rep_words));
@ -1012,7 +1012,7 @@ ROW *make_prop_words( //find lines
next_rep_char_word_right;
current_within_xht_gap = current_gap;
if (current_gap > tosp_rep_space * repetition_spacing) {
prev_blanks = (UINT8) floor (current_gap / row->space_size);
prev_blanks = (uinT8) floor (current_gap / row->space_size);
if (prev_blanks < 1)
prev_blanks = 1;
}
@ -1128,7 +1128,7 @@ ROW *make_prop_words( //find lines
current_within_xht_gap = current_gap;
if (current_gap > tosp_rep_space * repetition_spacing) {
blanks =
(UINT8) floor (current_gap / row->space_size);
(uinT8) floor (current_gap / row->space_size);
if (blanks < 1)
blanks = 1;
}
@ -1149,7 +1149,7 @@ ROW *make_prop_words( //find lines
current_gap =
blob_box.left () - next_rep_char_word_right;
if (current_gap > tosp_rep_space * repetition_spacing) {
blanks = (UINT8) (current_gap / row->space_size);
blanks = (uinT8) (current_gap / row->space_size);
if (blanks < 1)
blanks = 1;
}
@ -1195,7 +1195,7 @@ ROW *make_prop_words( //find lines
repetition_spacing = find_mean_blob_spacing (word);
current_gap = word->bounding_box ().left () - prev_x;
if (current_gap > tosp_rep_space * repetition_spacing) {
blanks = (UINT8) floor (current_gap / row->space_size);
blanks = (uinT8) floor (current_gap / row->space_size);
if (blanks < 1)
blanks = 1;
}
@ -1224,7 +1224,7 @@ ROW *make_prop_words( //find lines
coeffs[1] = row->line_m ();
coeffs[2] = row->line_c ();
real_row = new ROW (row,
(INT16) row->kern_size, (INT16) row->space_size);
(inT16) row->kern_size, (inT16) row->space_size);
word_it.set_to_list (real_row->word_list ());
//put words in row
word_it.add_list_after (&words);
@ -1246,19 +1246,19 @@ ROW *make_prop_words( //find lines
BOOL8 make_a_word_break( //decide on word break
TO_ROW *row, //row being made
BOX blob_box, //for next_blob //how many blanks?
INT16 prev_gap,
BOX prev_blob_box,
INT16 real_current_gap,
INT16 within_xht_current_gap,
BOX next_blob_box,
INT16 next_gap,
UINT8 &blanks,
TBOX blob_box, //for next_blob //how many blanks?
inT16 prev_gap,
TBOX prev_blob_box,
inT16 real_current_gap,
inT16 within_xht_current_gap,
TBOX next_blob_box,
inT16 next_gap,
uinT8 &blanks,
BOOL8 &fuzzy_sp,
BOOL8 &fuzzy_non) {
static BOOL8 prev_gap_was_a_space;
BOOL8 space;
INT16 current_gap;
inT16 current_gap;
float fuzzy_sp_to_kn_limit;
/* Inhibit using the reduced gap if
@ -1295,7 +1295,7 @@ BOOL8 make_a_word_break( //decide on word break
}
}
else {
blanks = (UINT8) (current_gap / row->space_size);
blanks = (uinT8) (current_gap / row->space_size);
if (blanks < 1)
blanks = 1;
fuzzy_sp = FALSE;
@ -1318,7 +1318,7 @@ BOOL8 make_a_word_break( //decide on word break
we may need to set PARTICULAR spaces to fuzzy or not. The values will ONLY
be used if the function returns TRUE - ie the word is to be broken.
*/
blanks = (UINT8) (current_gap / row->space_size);
blanks = (uinT8) (current_gap / row->space_size);
if (blanks < 1)
blanks = 1;
fuzzy_sp = FALSE;
@ -1540,7 +1540,7 @@ BOOL8 make_a_word_break( //decide on word break
}
BOOL8 narrow_blob(TO_ROW *row, BOX blob_box) {
BOOL8 narrow_blob(TO_ROW *row, TBOX blob_box) {
BOOL8 result;
result = ((blob_box.width () <= tosp_narrow_fraction * row->xheight) ||
@ -1550,7 +1550,7 @@ BOOL8 narrow_blob(TO_ROW *row, BOX blob_box) {
}
BOOL8 wide_blob(TO_ROW *row, BOX blob_box) {
BOOL8 wide_blob(TO_ROW *row, TBOX blob_box) {
BOOL8 result;
if (tosp_wide_fraction > 0) {
@ -1567,7 +1567,7 @@ BOOL8 wide_blob(TO_ROW *row, BOX blob_box) {
}
BOOL8 suspected_punct_blob(TO_ROW *row, BOX box) {
BOOL8 suspected_punct_blob(TO_ROW *row, TBOX box) {
BOOL8 result;
float baseline;
float blob_x_centre;
@ -1587,11 +1587,11 @@ BOOL8 suspected_punct_blob(TO_ROW *row, BOX box) {
void peek_at_next_gap( //A COPY FOR PEEKING
TO_ROW *row,
BLOBNBOX_IT box_it,
BOX &next_blob_box,
INT16 &next_gap,
INT16 &next_within_xht_gap) {
BOX next_reduced_blob_box;
BOX bit_beyond;
TBOX &next_blob_box,
inT16 &next_gap,
inT16 &next_within_xht_gap) {
TBOX next_reduced_blob_box;
TBOX bit_beyond;
BLOBNBOX_IT reduced_box_it = box_it;
next_blob_box = box_next (&box_it);
@ -1612,13 +1612,13 @@ void peek_at_next_gap( //A COPY FOR PEEKING
#ifndef GRAPHICS_DISABLED
void mark_gap( //Debug stuff
BOX blob, //blob following gap
INT16 rule, // heuristic id
INT16 prev_gap,
INT16 prev_blob_width,
INT16 current_gap,
INT16 next_blob_width,
INT16 next_gap) {
TBOX blob, //blob following gap
inT16 rule, // heuristic id
inT16 prev_gap,
inT16 prev_blob_width,
inT16 current_gap,
inT16 next_blob_width,
inT16 next_gap) {
ScrollView::Color col; //of ellipse marking flipped gap
switch (rule) {
@ -1664,7 +1664,7 @@ void mark_gap( //Debug stuff
col = ScrollView::BLACK;
}
if (textord_show_initial_words) {
to_win->Pen(col);
to_win->Pen(col);
/* if (rule < 20)
//interior_style(to_win, INT_SOLID, FALSE);
else
@ -1689,10 +1689,10 @@ void mark_gap( //Debug stuff
float find_mean_blob_spacing(WERD *word) {
PBLOB_IT blob_it;
C_BLOB_IT cblob_it;
BOX blob_box;
INT32 gap_sum = 0;
INT16 gap_count = 0;
INT16 prev_right;
TBOX blob_box;
inT32 gap_sum = 0;
inT16 gap_count = 0;
inT16 prev_right;
if (word->flag (W_POLYGON)) {
blob_it.set_to_list (word->blob_list ());
@ -1732,11 +1732,11 @@ float find_mean_blob_spacing(WERD *word) {
BOOL8 ignore_big_gap(TO_ROW *row,
INT32 row_length,
inT32 row_length,
GAPMAP *gapmap,
INT16 left,
INT16 right) {
INT16 gap = right - left + 1;
inT16 left,
inT16 right) {
inT16 gap = right - left + 1;
if (tosp_ignore_big_gaps > 999)
return FALSE; //Dont ignore
@ -1771,16 +1771,16 @@ BOOL8 ignore_big_gap(TO_ROW *row,
* DONT reduce the box for small things - eg punctuation.
**********************************************************************/
BOX reduced_box_next( //get bounding box
TBOX reduced_box_next( //get bounding box
TO_ROW *row, //current row
BLOBNBOX_IT *it //iterator to blobds
) {
BLOBNBOX *blob; //current blob
BLOBNBOX *head_blob; //place to store box
BOX full_box; //full blob boundg box
BOX reduced_box; //box of significant part
INT16 left_above_xht; //ABOVE xht left limit
INT16 new_left_above_xht; //ABOVE xht left limit
TBOX full_box; //full blob boundg box
TBOX reduced_box; //box of significant part
inT16 left_above_xht; //ABOVE xht left limit
inT16 new_left_above_xht; //ABOVE xht left limit
blob = it->data ();
if (blob->red_box_set ()) {
@ -1847,13 +1847,13 @@ BOX reduced_box_next( //get bounding box
* find_blob_limits finds the y min and max within a specified x band
*************************************************************************/
BOX reduced_box_for_blob(BLOBNBOX *blob, TO_ROW *row, INT16 *left_above_xht) {
TBOX reduced_box_for_blob(BLOBNBOX *blob, TO_ROW *row, inT16 *left_above_xht) {
float baseline;
float blob_x_centre;
float left_limit;
float right_limit;
float junk;
BOX blob_box;
TBOX blob_box;
/* Find baseline of centre of blob */
@ -1886,7 +1886,7 @@ BOX reduced_box_for_blob(BLOBNBOX *blob, TO_ROW *row, INT16 *left_above_xht) {
if (left_limit > junk)
*left_above_xht = MAX_INT16; //No area above xht
else
*left_above_xht = (INT16) floor (left_limit);
*left_above_xht = (inT16) floor (left_limit);
/*
Find reduced LH limit of blob - the left extent of the region ABOVE the
baseline.
@ -1909,7 +1909,7 @@ BOX reduced_box_for_blob(BLOBNBOX *blob, TO_ROW *row, INT16 *left_above_xht) {
left_limit, junk); //min y max_y
if (left_limit > junk)
return BOX (); //no area within xht so return empty box
return TBOX (); //no area within xht so return empty box
/*
Find reduced RH limit of blob - the right extent of the region BELOW the xht.
*/
@ -1932,8 +1932,8 @@ BOX reduced_box_for_blob(BLOBNBOX *blob, TO_ROW *row, INT16 *left_above_xht) {
// FCOORD( 0.0, 1.0 ), //90deg anticlock rot
junk, right_limit); //min y max_y
if (junk > right_limit)
return BOX (); //no area within xht so return empty box
return TBOX (); //no area within xht so return empty box
return BOX (ICOORD ((INT16) floor (left_limit), blob_box.bottom ()),
ICOORD ((INT16) ceil (right_limit), blob_box.top ()));
return TBOX (ICOORD ((inT16) floor (left_limit), blob_box.bottom ()),
ICOORD ((inT16) ceil (right_limit), blob_box.top ()));
}

View File

@ -119,75 +119,75 @@ void to_spacing( //set spacing
void block_spacing_stats(TO_BLOCK *block,
GAPMAP *gapmap,
BOOL8 &old_text_ord_proportional,
INT16 &block_space_gap_width, //resulting estimate
INT16 &block_non_space_gap_width //resulting estimate
inT16 &block_space_gap_width, //resulting estimate
inT16 &block_non_space_gap_width //resulting estimate
);
//estimate for block
void row_spacing_stats(TO_ROW *row,
GAPMAP *gapmap,
INT16 block_idx,
INT16 row_idx,
INT16 block_space_gap_width,
INT16 block_non_space_gap_width //estimate for block
inT16 block_idx,
inT16 row_idx,
inT16 block_space_gap_width,
inT16 block_non_space_gap_width //estimate for block
);
//estimate for block
void old_to_method(TO_ROW *row,
STATS *all_gap_stats,
STATS *space_gap_stats,
STATS *small_gap_stats,
INT16 block_space_gap_width,
INT16 block_non_space_gap_width //estimate for block
inT16 block_space_gap_width,
inT16 block_non_space_gap_width //estimate for block
);
BOOL8 isolated_row_stats(TO_ROW *row,
GAPMAP *gapmap,
STATS *all_gap_stats,
BOOL8 suspected_table,
INT16 block_idx,
INT16 row_idx);
INT16 stats_count_under(STATS *stats, INT16 threshold);
void improve_row_threshold(TO_ROW *row, STATS *all_gap_stats);
inT16 block_idx,
inT16 row_idx);
inT16 stats_count_under(STATS *stats, inT16 threshold);
void improve_row_threshold(TO_ROW *row, STATS *all_gap_stats);
ROW *make_prop_words( //find lines
TO_ROW *row, //row to make
FCOORD rotation //for drawing
);
BOOL8 make_a_word_break( //decide on word break
TO_ROW *row, //row being made
BOX blob_box, //for next_blob //how many blanks?
INT16 prev_gap,
BOX prev_blob_box,
INT16 real_current_gap,
INT16 within_xht_current_gap,
BOX next_blob_box,
INT16 next_gap,
UINT8 &blanks,
TBOX blob_box, //for next_blob //how many blanks?
inT16 prev_gap,
TBOX prev_blob_box,
inT16 real_current_gap,
inT16 within_xht_current_gap,
TBOX next_blob_box,
inT16 next_gap,
uinT8 &blanks,
BOOL8 &fuzzy_sp,
BOOL8 &fuzzy_non);
BOOL8 narrow_blob(TO_ROW *row, BOX blob_box);
BOOL8 wide_blob(TO_ROW *row, BOX blob_box);
BOOL8 suspected_punct_blob(TO_ROW *row, BOX box);
BOOL8 narrow_blob(TO_ROW *row, TBOX blob_box);
BOOL8 wide_blob(TO_ROW *row, TBOX blob_box);
BOOL8 suspected_punct_blob(TO_ROW *row, TBOX box);
//A COPY FOR PEEKING
void peek_at_next_gap(TO_ROW *row,
BLOBNBOX_IT box_it,
BOX &next_blob_box,
INT16 &next_gap,
INT16 &next_within_xht_gap);
TBOX &next_blob_box,
inT16 &next_gap,
inT16 &next_within_xht_gap);
void mark_gap( //Debug stuff
BOX blob, //blob following gap
INT16 rule, // heuristic id
INT16 prev_gap,
INT16 prev_blob_width,
INT16 current_gap,
INT16 next_blob_width,
INT16 next_gap);
float find_mean_blob_spacing(WERD *word);
TBOX blob, //blob following gap
inT16 rule, // heuristic id
inT16 prev_gap,
inT16 prev_blob_width,
inT16 current_gap,
inT16 next_blob_width,
inT16 next_gap);
float find_mean_blob_spacing(WERD *word);
BOOL8 ignore_big_gap(TO_ROW *row,
INT32 row_length,
inT32 row_length,
GAPMAP *gapmap,
INT16 left,
INT16 right);
BOX reduced_box_next( //get bounding box
inT16 left,
inT16 right);
TBOX reduced_box_next( //get bounding box
TO_ROW *row, //current row
BLOBNBOX_IT *it //iterator to blobds
);
BOX reduced_box_for_blob(BLOBNBOX *blob, TO_ROW *row, INT16 *left_above_xht);
TBOX reduced_box_for_blob(BLOBNBOX *blob, TO_ROW *row, inT16 *left_above_xht);
#endif

View File

@ -39,8 +39,8 @@ EXTERN BOOL_VAR (textord_restore_underlines, TRUE,
void restore_underlined_blobs( //get chop points
TO_BLOCK *block //block to do
) {
INT16 chop_coord; //chop boundary
BOX blob_box; //of underline
inT16 chop_coord; //chop boundary
TBOX blob_box; //of underline
BLOBNBOX *u_line; //underline bit
TO_ROW *row; //best row for blob
ICOORDELT_LIST chop_cells; //blobs to cut out
@ -146,7 +146,7 @@ TO_ROW *most_overlapping_row( //find best row
TO_ROW_LIST *rows, //list of rows
BLOBNBOX *blob //blob to place
) {
INT16 x = (blob->bounding_box ().left ()
inT16 x = (blob->bounding_box ().left ()
+ blob->bounding_box ().right ()) / 2;
TO_ROW_IT row_it = rows; //row iterator
TO_ROW *row; //current row
@ -206,9 +206,9 @@ void find_underlined_blobs( //get chop points
float baseline_offset, //amount to shrinke it
ICOORDELT_LIST *chop_cells //places to chop
) {
INT16 x, y; //sides of blob
inT16 x, y; //sides of blob
ICOORD blob_chop; //sides of blob
BOX blob_box = u_line->bounding_box ();
TBOX blob_box = u_line->bounding_box ();
//cell iterator
ICOORDELT_IT cell_it = chop_cells;
STATS upper_proj (blob_box.left (), blob_box.right () + 1);
@ -255,9 +255,9 @@ void vertical_cunderline_projection( //project outlines
) {
ICOORD pos; //current point
ICOORD step; //edge step
INT16 lower_y, upper_y; //region limits
INT32 length; //of outline
INT16 stepindex; //current step
inT16 lower_y, upper_y; //region limits
inT32 length; //of outline
inT16 stepindex; //current step
C_OUTLINE_IT out_it = outline->child ();
pos = outline->start_pos ();
@ -266,9 +266,9 @@ void vertical_cunderline_projection( //project outlines
step = outline->step (stepindex);
if (step.x () > 0) {
lower_y =
(INT16) floor (baseline->y (pos.x ()) + baseline_offset + 0.5);
(inT16) floor (baseline->y (pos.x ()) + baseline_offset + 0.5);
upper_y =
(INT16) floor (baseline->y (pos.x ()) + baseline_offset +
(inT16) floor (baseline->y (pos.x ()) + baseline_offset +
xheight + 0.5);
if (pos.y () >= lower_y) {
lower_proj->add (pos.x (), -lower_y);
@ -284,10 +284,10 @@ void vertical_cunderline_projection( //project outlines
}
else if (step.x () < 0) {
lower_y =
(INT16) floor (baseline->y (pos.x () - 1) + baseline_offset +
(inT16) floor (baseline->y (pos.x () - 1) + baseline_offset +
0.5);
upper_y =
(INT16) floor (baseline->y (pos.x () - 1) + baseline_offset +
(inT16) floor (baseline->y (pos.x () - 1) + baseline_offset +
xheight + 0.5);
if (pos.y () >= lower_y) {
lower_proj->add (pos.x () - 1, lower_y);

View File

@ -66,7 +66,7 @@ void make_words( //make words
global_monitor->ocr_alive = TRUE;
global_monitor->progress = 25;
}
to_spacing(page_tr, port_blocks);
to_spacing(page_tr, port_blocks);
block_it.set_to_list (port_blocks);
for (block_it.mark_cycle_pt (); !block_it.cycled_list ();
block_it.forward ()) {
@ -90,13 +90,13 @@ void set_row_spaces( //find space sizes
FCOORD rotation, //for drawing
BOOL8 testing_on //correct orientation
) {
INT32 maxwidth; //of widest space
inT32 maxwidth; //of widest space
TO_ROW *row; //current row
TO_ROW_IT row_it = block->get_rows ();
if (row_it.empty ())
return; //empty block
maxwidth = (INT32) ceil (block->xheight * textord_words_maxspace);
maxwidth = (inT32) ceil (block->xheight * textord_words_maxspace);
for (row_it.mark_cycle_pt (); !row_it.cycled_list (); row_it.forward ()) {
row = row_it.data ();
if (row->fixed_pitch == 0) {
@ -106,11 +106,11 @@ void set_row_spaces( //find space sizes
// && row_words2(block,row,maxwidth,rotation,testing_on)==0)
// {
row->min_space =
(INT32) ceil (row->pr_space -
(inT32) ceil (row->pr_space -
(row->pr_space -
row->pr_nonsp) * textord_words_definite_spread);
row->max_nonspace =
(INT32) floor (row->pr_nonsp +
(inT32) floor (row->pr_nonsp +
(row->pr_space -
row->pr_nonsp) * textord_words_definite_spread);
if (testing_on && textord_show_initial_words) {
@ -124,7 +124,7 @@ void set_row_spaces( //find space sizes
}
#ifndef GRAPHICS_DISABLED
if (textord_show_initial_words && testing_on) {
plot_word_decisions (to_win, (INT16) row->fixed_pitch, row);
plot_word_decisions (to_win, (inT16) row->fixed_pitch, row);
}
#endif
}
@ -137,26 +137,26 @@ void set_row_spaces( //find space sizes
* Compute the max nonspace and min space for the row.
**********************************************************************/
INT32 row_words( //compute space size
inT32 row_words( //compute space size
TO_BLOCK *block, //block it came from
TO_ROW *row, //row to operate on
INT32 maxwidth, //max expected space size
inT32 maxwidth, //max expected space size
FCOORD rotation, //for drawing
BOOL8 testing_on //for debug
) {
BOOL8 testing_row; //contains testpt
BOOL8 prev_valid; //if decent size
BOOL8 this_valid; //current blob big enough
INT32 prev_x; //end of prev blob
INT32 min_gap; //min interesting gap
INT32 cluster_count; //no of clusters
INT32 gap_index; //which cluster
INT32 smooth_factor; //for smoothing stats
inT32 prev_x; //end of prev blob
inT32 min_gap; //min interesting gap
inT32 cluster_count; //no of clusters
inT32 gap_index; //which cluster
inT32 smooth_factor; //for smoothing stats
BLOBNBOX *blob; //current blob
float lower, upper; //clustering parameters
float gaps[3]; //gap clusers
ICOORD testpt;
BOX blob_box; //bounding box
TBOX blob_box; //bounding box
//iterator
BLOBNBOX_IT blob_it = row->blob_list ();
STATS gap_stats (0, maxwidth);
@ -164,7 +164,7 @@ INT32 row_words( //compute space size
testpt = ICOORD (textord_test_x, textord_test_y);
smooth_factor =
(INT32) (block->xheight * textord_wordstats_smooth_factor + 1.5);
(inT32) (block->xheight * textord_wordstats_smooth_factor + 1.5);
// if (testing_on)
// tprintf("Row smooth factor=%d\n",smooth_factor);
prev_valid = FALSE;
@ -177,7 +177,7 @@ INT32 row_words( //compute space size
testing_row = TRUE;
gap_stats.add (blob_box.width (), 1);
}
min_gap = (INT32) floor (gap_stats.ile (textord_words_width_ile));
min_gap = (inT32) floor (gap_stats.ile (textord_words_width_ile));
gap_stats.clear ();
for (blob_it.mark_cycle_pt (); !blob_it.cycled_list (); blob_it.forward ()) {
blob = blob_it.data ();
@ -281,9 +281,9 @@ INT32 row_words( //compute space size
}
}
row->min_space =
(INT32) ceil (upper - (upper - lower) * textord_words_definite_spread);
(inT32) ceil (upper - (upper - lower) * textord_words_definite_spread);
row->max_nonspace =
(INT32) floor (lower + (upper - lower) * textord_words_definite_spread);
(inT32) floor (lower + (upper - lower) * textord_words_definite_spread);
row->space_threshold = (row->max_nonspace + row->min_space) / 2;
row->space_size = upper;
row->kern_size = lower;
@ -310,28 +310,28 @@ INT32 row_words( //compute space size
* Compute the max nonspace and min space for the row.
**********************************************************************/
INT32 row_words2( //compute space size
inT32 row_words2( //compute space size
TO_BLOCK *block, //block it came from
TO_ROW *row, //row to operate on
INT32 maxwidth, //max expected space size
inT32 maxwidth, //max expected space size
FCOORD rotation, //for drawing
BOOL8 testing_on //for debug
) {
BOOL8 testing_row; //contains testpt
BOOL8 prev_valid; //if decent size
BOOL8 this_valid; //current blob big enough
INT32 prev_x; //end of prev blob
INT32 min_width; //min interesting width
INT32 valid_count; //good gaps
INT32 total_count; //total gaps
INT32 cluster_count; //no of clusters
INT32 prev_count; //previous cluster_count
INT32 gap_index; //which cluster
INT32 smooth_factor; //for smoothing stats
inT32 prev_x; //end of prev blob
inT32 min_width; //min interesting width
inT32 valid_count; //good gaps
inT32 total_count; //total gaps
inT32 cluster_count; //no of clusters
inT32 prev_count; //previous cluster_count
inT32 gap_index; //which cluster
inT32 smooth_factor; //for smoothing stats
BLOBNBOX *blob; //current blob
float lower, upper; //clustering parameters
ICOORD testpt;
BOX blob_box; //bounding box
TBOX blob_box; //bounding box
//iterator
BLOBNBOX_IT blob_it = row->blob_list ();
STATS gap_stats (0, maxwidth);
@ -342,14 +342,14 @@ INT32 row_words2( //compute space size
testpt = ICOORD (textord_test_x, textord_test_y);
smooth_factor =
(INT32) (block->xheight * textord_wordstats_smooth_factor + 1.5);
(inT32) (block->xheight * textord_wordstats_smooth_factor + 1.5);
// if (testing_on)
// tprintf("Row smooth factor=%d\n",smooth_factor);
prev_valid = FALSE;
prev_x = -MAX_INT16;
testing_row = FALSE;
//min blob size
min_width = (INT32) block->pr_space;
min_width = (inT32) block->pr_space;
total_count = 0;
for (blob_it.mark_cycle_pt (); !blob_it.cycled_list (); blob_it.forward ()) {
blob = blob_it.data ();
@ -437,9 +437,9 @@ INT32 row_words2( //compute space size
upper = block->pr_space;
}
row->min_space =
(INT32) ceil (upper - (upper - lower) * textord_words_definite_spread);
(inT32) ceil (upper - (upper - lower) * textord_words_definite_spread);
row->max_nonspace =
(INT32) floor (lower + (upper - lower) * textord_words_definite_spread);
(inT32) floor (lower + (upper - lower) * textord_words_definite_spread);
row->space_threshold = (row->max_nonspace + row->min_space) / 2;
row->space_size = upper;
row->kern_size = lower;
@ -491,16 +491,16 @@ void make_real_words( //find lines
|| row->pitch_decision == PITCH_CORR_PROP)
real_row = make_prop_words (row, rotation);
else
ASSERT_HOST(FALSE);
ASSERT_HOST(FALSE);
}
if (real_row != NULL) {
//put row in block
real_row_it.add_after_then_move (real_row);
}
}
block->block->set_stats (block->fixed_pitch == 0, (INT16) block->kern_size,
(INT16) block->space_size,
(INT16) block->fixed_pitch);
block->block->set_stats (block->fixed_pitch == 0, (inT16) block->kern_size,
(inT16) block->space_size,
(inT16) block->fixed_pitch);
block->block->check_pitch ();
}
@ -516,9 +516,9 @@ ROW *make_rep_words( //make a row
TO_ROW *row, //row to convert
TO_BLOCK *block //block it lives in
) {
INT32 xstarts[2]; //ends of row
inT32 xstarts[2]; //ends of row
ROW *real_row; //output row
BOX word_box; //bounding box
TBOX word_box; //bounding box
double coeffs[3]; //spline
//iterator
WERD_IT word_it = &row->rep_words;
@ -535,7 +535,7 @@ ROW *make_rep_words( //make a row
coeffs[2] = row->line_c ();
row->xheight = block->xheight;
real_row = new ROW (row,
(INT16) block->kern_size, (INT16) block->space_size);
(inT16) block->kern_size, (inT16) block->space_size);
word_it.set_to_list (real_row->word_list ());
//put words in row
word_it.add_list_after (&row->rep_words);
@ -553,11 +553,11 @@ ROW *make_rep_words( //make a row
WERD *make_real_word( //make a WERD
BLOBNBOX_IT *box_it, //iterator
INT32 blobcount, //no of blobs to use
inT32 blobcount, //no of blobs to use
BOOL8 bol, //start of line
BOOL8 fuzzy_sp, //fuzzy space
BOOL8 fuzzy_non, //fuzzy non-space
UINT8 blanks //no of blanks
uinT8 blanks //no of blanks
) {
OUTLINE_IT out_it; //outlines
C_OUTLINE_IT cout_it;
@ -567,7 +567,7 @@ WERD *make_real_word( //make a WERD
C_BLOB_IT cblob_it = &cblobs;
WERD *word; //new word
BLOBNBOX *bblob; //current blob
INT32 blobindex; //in row
inT32 blobindex; //in row
for (blobindex = 0; blobindex < blobcount; blobindex++) {
bblob = box_it->extract ();

View File

@ -37,17 +37,17 @@ void set_row_spaces( //find space sizes
FCOORD rotation, //for drawing
BOOL8 testing_on //correct orientation
);
INT32 row_words( //compute space size
inT32 row_words( //compute space size
TO_BLOCK *block, //block it came from
TO_ROW *row, //row to operate on
INT32 maxwidth, //max expected space size
inT32 maxwidth, //max expected space size
FCOORD rotation, //for drawing
BOOL8 testing_on //for debug
);
INT32 row_words2( //compute space size
inT32 row_words2( //compute space size
TO_BLOCK *block, //block it came from
TO_ROW *row, //row to operate on
INT32 maxwidth, //max expected space size
inT32 maxwidth, //max expected space size
FCOORD rotation, //for drawing
BOOL8 testing_on //for debug
);
@ -61,10 +61,10 @@ ROW *make_rep_words( //make a row
);
WERD *make_real_word( //make a WERD
BLOBNBOX_IT *box_it, //iterator
INT32 blobcount, //no of blobs to use
inT32 blobcount, //no of blobs to use
BOOL8 bol, //start of line
BOOL8 fuzzy_sp, //fuzzy space
BOOL8 fuzzy_non, //fuzzy non-space
UINT8 blanks //no of blanks
uinT8 blanks //no of blanks
);
#endif