Tesseract 3.02

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

- File List
- File Members

All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
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 #include "notdll.h"
26
27 extern BOOL_VAR_H (textord_really_old_xheight, FALSE,
28 "Use original wiseowl xheight");
29 extern BOOL_VAR_H (textord_oldbl_debug, FALSE,
30 "Debug old baseline generation");
31 extern BOOL_VAR_H (textord_debug_baselines, FALSE,
32 "Debug baseline generation");
33 extern BOOL_VAR_H (textord_oldbl_paradef, TRUE, "Use para default mechanism");
34 extern BOOL_VAR_H (textord_oldbl_split_splines, TRUE,
35 "Split stepped splines");
36 extern BOOL_VAR_H (textord_oldbl_merge_parts, TRUE,
37 "Merge suspect partitions");
38 extern BOOL_VAR_H (oldbl_xhfix, FALSE,
39 "Fix bug in modes threshold for xheights");
40 extern INT_VAR_H (oldbl_holed_losscount, 10,
41 "Max lost before fallback line used");
42 extern double_VAR_H (oldbl_dot_error_size, 1.26, "Max aspect ratio of a dot");
43 extern double_VAR_H (textord_oldbl_jumplimit, 0.15,
44 "X fraction for new partition");
45 int get_blob_coords( //get boxes
46 TO_ROW *row, //row to use
47 inT32 lineheight, //block level
48 TBOX *blobcoords, //ouput boxes
49 BOOL8 &holed_line, //lost a lot of blobs
50 int &outcount //no of real blobs
51 );
52 void make_first_baseline ( //initial approximation
53 TBOX blobcoords[], /*blob bounding boxes */
54 int blobcount, /*no of blobcoords */
55 int xcoords[], /*coords for spline */
56 int ycoords[], /*approximator */
57 QSPLINE * spline, /*initial spline */
58 QSPLINE * baseline, /*output spline */
59 float jumplimit /*guess half descenders */
60 );
61 void make_holed_baseline ( //initial approximation
62 TBOX blobcoords[], /*blob bounding boxes */
63 int blobcount, /*no of blobcoords */
64 QSPLINE * spline, /*initial spline */
65 QSPLINE * baseline, /*output spline */
66 float gradient //of line
67 );
68 int partition_line ( //partition blobs
69 TBOX blobcoords[], //bounding boxes
70 int blobcount, /*no of blobs on row */
71 int *numparts, /*number of partitions */
72 char partids[], /*partition no of each blob */
73 int partsizes[], /*no in each partition */
74 QSPLINE * spline, /*curve to fit to */
75 float jumplimit, /*allowed delta change */
76 float ydiffs[] /*diff from spline */
77 );
78 void merge_oldbl_parts ( //partition blobs
79 TBOX blobcoords[], //bounding boxes
80 int blobcount, /*no of blobs on row */
81 char partids[], /*partition no of each blob */
82 int partsizes[], /*no in each partition */
83 int biggestpart, //major partition
84 float jumplimit /*allowed delta change */
85 );
86 int get_ydiffs ( //evaluate differences
87 TBOX blobcoords[], //bounding boxes
88 int blobcount, /*no of blobs */
89 QSPLINE * spline, /*approximating spline */
90 float ydiffs[] /*output */
91 );
92 int choose_partition ( //select partition
93 register float diff, /*diff from spline */
94 float partdiffs[], /*diff on all parts */
95 int lastpart, /*last assigned partition */
96 float jumplimit, /*new part threshold */
97 float* drift,
98 float* last_delta,
99 int *partcount /*no of partitions */
100 );
101 int partition_coords ( //find relevant coords
102 TBOX blobcoords[], //bounding boxes
103 int blobcount, /*no of blobs in row */
104 char partids[], /*partition no of each blob */
105 int bestpart, /*best new partition */
106 int xcoords[], /*points to work on */
107 int ycoords[] /*points to work on */
108 );
109 int segment_spline ( //make xstarts
110 TBOX blobcoords[], //boundign boxes
111 int blobcount, /*no of blobs in row */
112 int xcoords[], /*points to work on */
113 int ycoords[], /*points to work on */
114 int degree, int pointcount, /*no of points */
115 int xstarts[] //result
116 );
117 BOOL8 split_stepped_spline ( //make xstarts
118 QSPLINE * baseline, //current shot
119 float jumplimit, //max step fuction
120 int xcoords[], /*points to work on */
121 int xstarts[], //result
122 int &segments //no of segments
123 );
124 void insert_spline_point ( //get descenders
125 int xstarts[], //starts to shuffle
126 int segment, //insertion pt
127 int coord1, //coords to add
128 int coord2, int &segments //total segments
129 );
130 void find_lesser_parts ( //get descenders
131 TO_ROW * row, //row to process
132 TBOX blobcoords[], //bounding boxes
133 int blobcount, /*no of blobs */
134 char partids[], /*partition of each blob */
135 int partsizes[], /*size of each part */
136 int partcount, /*no of partitions */
137 int bestpart /*biggest partition */
138 );
139
140 void old_first_xheight ( //the wiseowl way
141 TO_ROW * row, /*current row */
142 TBOX blobcoords[], /*blob bounding boxes */
143 int initialheight, //initial guess
144 int blobcount, /*blobs in blobcoords */
145 QSPLINE * baseline, /*established */
146 float jumplimit /*min ascender height */
147 );
148
149 void make_first_xheight ( //find xheight
150 TO_ROW * row, /*current row */
151 TBOX blobcoords[], /*blob bounding boxes */
152 int lineheight, //initial guess
153 int init_lineheight, //block level guess
154 int blobcount, /*blobs in blobcoords */
155 QSPLINE * baseline, /*established */
156 float jumplimit /*min ascender height */
157 );
158
159 int *make_height_array ( //get array of heights
160 TBOX blobcoords[], /*blob bounding boxes */
161 int blobcount, /*blobs in blobcoords */
162 QSPLINE * baseline /*established */
163 );
164
165 void find_top_modes ( //get modes
166 STATS * stats, //stats to hack
167 int statnum, //no of piles
168 int modelist[], int modenum //no of modes to get
169 );
170
171 void pick_x_height(TO_ROW * row, //row to do
172 int modelist[],
173 int lefts[], int rights[],
174 STATS * heightstat,
175 int mode_threshold);
176 #endif