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