All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
oldbasel.h
Go to the documentation of this file.
1 /**********************************************************************
2  * File: oldbasel.h (Formerly oldbl.h)
3  * Description: A re-implementation of the old baseline algorithm.
4  * Author: Ray Smith
5  * Created: Wed Oct 6 09:41:48 BST 1993
6  *
7  * (C) Copyright 1993, Hewlett-Packard Ltd.
8  ** Licensed under the Apache License, Version 2.0 (the "License");
9  ** you may not use this file except in compliance with the License.
10  ** You may obtain a copy of the License at
11  ** http://www.apache.org/licenses/LICENSE-2.0
12  ** Unless required by applicable law or agreed to in writing, software
13  ** distributed under the License is distributed on an "AS IS" BASIS,
14  ** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15  ** See the License for the specific language governing permissions and
16  ** limitations under the License.
17  *
18  **********************************************************************/
19 
20 #ifndef OLDBASEL_H
21 #define OLDBASEL_H
22 
23 #include "params.h"
24 #include "blobbox.h"
25 
27 "Use original wiseowl xheight");
29 "Debug old baseline generation");
31 "Debug baseline generation");
32 extern BOOL_VAR_H (textord_oldbl_paradef, TRUE, "Use para default mechanism");
34 "Split stepped splines");
36 "Merge suspect partitions");
38 "Fix bug in modes threshold for xheights");
40 "Max lost before fallback line used");
41 extern double_VAR_H (oldbl_dot_error_size, 1.26, "Max aspect ratio of a dot");
43 "X fraction for new partition");
44 int get_blob_coords( //get boxes
45  TO_ROW *row, //row to use
46  inT32 lineheight, //block level
47  TBOX *blobcoords, //ouput boxes
48  BOOL8 &holed_line, //lost a lot of blobs
49  int &outcount //no of real blobs
50  );
51 void make_first_baseline ( //initial approximation
52 TBOX blobcoords[], /*blob bounding boxes */
53 int blobcount, /*no of blobcoords */
54 int xcoords[], /*coords for spline */
55 int ycoords[], /*approximator */
56 QSPLINE * spline, /*initial spline */
57 QSPLINE * baseline, /*output spline */
58 float jumplimit /*guess half descenders */
59 );
60 void make_holed_baseline ( //initial approximation
61 TBOX blobcoords[], /*blob bounding boxes */
62 int blobcount, /*no of blobcoords */
63 QSPLINE * spline, /*initial spline */
64 QSPLINE * baseline, /*output spline */
65 float gradient //of line
66 );
67 int partition_line ( //partition blobs
68 TBOX blobcoords[], //bounding boxes
69 int blobcount, /*no of blobs on row */
70 int *numparts, /*number of partitions */
71 char partids[], /*partition no of each blob */
72 int partsizes[], /*no in each partition */
73 QSPLINE * spline, /*curve to fit to */
74 float jumplimit, /*allowed delta change */
75 float ydiffs[] /*diff from spline */
76 );
77 void merge_oldbl_parts ( //partition blobs
78 TBOX blobcoords[], //bounding boxes
79 int blobcount, /*no of blobs on row */
80 char partids[], /*partition no of each blob */
81 int partsizes[], /*no in each partition */
82 int biggestpart, //major partition
83 float jumplimit /*allowed delta change */
84 );
85 int get_ydiffs ( //evaluate differences
86 TBOX blobcoords[], //bounding boxes
87 int blobcount, /*no of blobs */
88 QSPLINE * spline, /*approximating spline */
89 float ydiffs[] /*output */
90 );
91 int choose_partition ( //select partition
92 register float diff, /*diff from spline */
93 float partdiffs[], /*diff on all parts */
94 int lastpart, /*last assigned partition */
95 float jumplimit, /*new part threshold */
96 float* drift,
97 float* last_delta,
98 int *partcount /*no of partitions */
99 );
100 int partition_coords ( //find relevant coords
101 TBOX blobcoords[], //bounding boxes
102 int blobcount, /*no of blobs in row */
103 char partids[], /*partition no of each blob */
104 int bestpart, /*best new partition */
105 int xcoords[], /*points to work on */
106 int ycoords[] /*points to work on */
107 );
108 int segment_spline ( //make xstarts
109 TBOX blobcoords[], //boundign boxes
110 int blobcount, /*no of blobs in row */
111 int xcoords[], /*points to work on */
112 int ycoords[], /*points to work on */
113 int degree, int pointcount, /*no of points */
114 int xstarts[] //result
115 );
116 BOOL8 split_stepped_spline ( //make xstarts
117 QSPLINE * baseline, //current shot
118 float jumplimit, //max step fuction
119 int xcoords[], /*points to work on */
120 int xstarts[], //result
121 int &segments //no of segments
122 );
123 void insert_spline_point ( //get descenders
124 int xstarts[], //starts to shuffle
125 int segment, //insertion pt
126 int coord1, //coords to add
127 int coord2, int &segments //total segments
128 );
129 void find_lesser_parts ( //get descenders
130 TO_ROW * row, //row to process
131 TBOX blobcoords[], //bounding boxes
132 int blobcount, /*no of blobs */
133 char partids[], /*partition of each blob */
134 int partsizes[], /*size of each part */
135 int partcount, /*no of partitions */
136 int bestpart /*biggest partition */
137 );
138 
139 void old_first_xheight ( //the wiseowl way
140 TO_ROW * row, /*current row */
141 TBOX blobcoords[], /*blob bounding boxes */
142 int initialheight, //initial guess
143 int blobcount, /*blobs in blobcoords */
144 QSPLINE * baseline, /*established */
145 float jumplimit /*min ascender height */
146 );
147 
148 void make_first_xheight ( //find xheight
149 TO_ROW * row, /*current row */
150 TBOX blobcoords[], /*blob bounding boxes */
151 int lineheight, //initial guess
152 int init_lineheight, //block level guess
153 int blobcount, /*blobs in blobcoords */
154 QSPLINE * baseline, /*established */
155 float jumplimit /*min ascender height */
156 );
157 
158 int *make_height_array ( //get array of heights
159 TBOX blobcoords[], /*blob bounding boxes */
160 int blobcount, /*blobs in blobcoords */
161 QSPLINE * baseline /*established */
162 );
163 
164 void find_top_modes ( //get modes
165 STATS * stats, //stats to hack
166 int statnum, //no of piles
167 int modelist[], int modenum //no of modes to get
168 );
169 
170 void pick_x_height(TO_ROW * row, //row to do
171 int modelist[],
172 int lefts[], int rights[],
173 STATS * heightstat,
174 int mode_threshold);
175 #endif
bool textord_oldbl_paradef
Definition: oldbasel.cpp:41
void old_first_xheight(TO_ROW *row, TBOX blobcoords[], int initialheight, int blobcount, QSPLINE *baseline, float jumplimit)
Definition: oldbasel.cpp:1454
int get_ydiffs(TBOX blobcoords[], int blobcount, QSPLINE *spline, float ydiffs[])
Definition: oldbasel.cpp:906
bool textord_oldbl_merge_parts
Definition: oldbasel.cpp:43
bool textord_really_old_xheight
Definition: oldbasel.cpp:38
#define INT_VAR_H(name, val, comment)
Definition: params.h:265
bool textord_debug_baselines
Definition: oldbasel.cpp:40
double oldbl_dot_error_size
Definition: oldbasel.cpp:51
Definition: statistc.h:33
int segment_spline(TBOX blobcoords[], int blobcount, int xcoords[], int ycoords[], int degree, int pointcount, int xstarts[])
Definition: oldbasel.cpp:1115
unsigned char BOOL8
Definition: host.h:113
bool textord_oldbl_split_splines
Definition: oldbasel.cpp:42
void insert_spline_point(int xstarts[], int segment, int coord1, int coord2, int &segments)
Definition: oldbasel.cpp:1347
void make_first_xheight(TO_ROW *row, TBOX blobcoords[], int lineheight, int init_lineheight, int blobcount, QSPLINE *baseline, float jumplimit)
Definition: oldbasel.cpp:1539
BOOL8 split_stepped_spline(QSPLINE *baseline, float jumplimit, int xcoords[], int xstarts[], int &segments)
Definition: oldbasel.cpp:1240
double textord_oldbl_jumplimit
Definition: oldbasel.cpp:53
void merge_oldbl_parts(TBOX blobcoords[], int blobcount, char partids[], int partsizes[], int biggestpart, float jumplimit)
Definition: oldbasel.cpp:793
int partition_coords(TBOX blobcoords[], int blobcount, char partids[], int bestpart, int xcoords[], int ycoords[])
*merge_partitions(partids,partcount,blobcount,bestpart) discards funny looking
Definition: oldbasel.cpp:1084
bool oldbl_xhfix
Definition: oldbasel.cpp:46
int oldbl_holed_losscount
Definition: oldbasel.cpp:50
#define double_VAR_H(name, val, comment)
Definition: params.h:274
void make_first_baseline(TBOX blobcoords[], int blobcount, int xcoords[], int ycoords[], QSPLINE *spline, QSPLINE *baseline, float jumplimit)
Definition: oldbasel.cpp:511
void pick_x_height(TO_ROW *row, int modelist[], int lefts[], int rights[], STATS *heightstat, int mode_threshold)
Definition: oldbasel.cpp:1664
int get_blob_coords(TO_ROW *row, inT32 lineheight, TBOX *blobcoords, BOOL8 &holed_line, int &outcount)
Definition: oldbasel.cpp:441
#define FALSE
Definition: capi.h:29
int choose_partition(register float diff, float partdiffs[], int lastpart, float jumplimit, float *drift, float *last_delta, int *partcount)
Definition: oldbasel.cpp:957
Definition: rect.h:30
#define TRUE
Definition: capi.h:28
void find_top_modes(STATS *stats, int statnum, int modelist[], int modenum)
Definition: oldbasel.cpp:1624
bool textord_oldbl_debug
Definition: oldbasel.cpp:39
int * make_height_array(TBOX blobcoords[], int blobcount, QSPLINE *baseline)
void make_holed_baseline(TBOX blobcoords[], int blobcount, QSPLINE *spline, QSPLINE *baseline, float gradient)
Definition: oldbasel.cpp:654
int partition_line(TBOX blobcoords[], int blobcount, int *numparts, char partids[], int partsizes[], QSPLINE *spline, float jumplimit, float ydiffs[])
Definition: oldbasel.cpp:712
#define BOOL_VAR_H(name, val, comment)
Definition: params.h:268
void find_lesser_parts(TO_ROW *row, TBOX blobcoords[], int blobcount, char partids[], int partsizes[], int partcount, int bestpart)
Definition: oldbasel.cpp:1371
int inT32
Definition: host.h:102