tesseract  5.0.0-alpha-619-ge9db
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 
25 extern BOOL_VAR_H (textord_oldbl_debug, false,
26 "Debug old baseline generation");
27 
28 int get_blob_coords( //get boxes
29  TO_ROW* row, //row to use
30  int32_t lineheight, //block level
31  TBOX* blobcoords, //output boxes
32  bool& holed_line, //lost a lot of blobs
33  int& outcount //no of real blobs
34 );
35 void make_first_baseline ( //initial approximation
36 TBOX blobcoords[], /*blob bounding boxes */
37 int blobcount, /*no of blobcoords */
38 int xcoords[], /*coords for spline */
39 int ycoords[], /*approximator */
40 QSPLINE * spline, /*initial spline */
41 QSPLINE * baseline, /*output spline */
42 float jumplimit /*guess half descenders */
43 );
44 void make_holed_baseline ( //initial approximation
45 TBOX blobcoords[], /*blob bounding boxes */
46 int blobcount, /*no of blobcoords */
47 QSPLINE * spline, /*initial spline */
48 QSPLINE * baseline, /*output spline */
49 float gradient //of line
50 );
51 int partition_line ( //partition blobs
52 TBOX blobcoords[], //bounding boxes
53 int blobcount, /*no of blobs on row */
54 int *numparts, /*number of partitions */
55 char partids[], /*partition no of each blob */
56 int partsizes[], /*no in each partition */
57 QSPLINE * spline, /*curve to fit to */
58 float jumplimit, /*allowed delta change */
59 float ydiffs[] /*diff from spline */
60 );
61 void merge_oldbl_parts ( //partition blobs
62 TBOX blobcoords[], //bounding boxes
63 int blobcount, /*no of blobs on row */
64 char partids[], /*partition no of each blob */
65 int partsizes[], /*no in each partition */
66 int biggestpart, //major partition
67 float jumplimit /*allowed delta change */
68 );
69 int get_ydiffs ( //evaluate differences
70 TBOX blobcoords[], //bounding boxes
71 int blobcount, /*no of blobs */
72 QSPLINE * spline, /*approximating spline */
73 float ydiffs[] /*output */
74 );
75 int choose_partition ( //select partition
76 float diff, /*diff from spline */
77 float partdiffs[], /*diff on all parts */
78 int lastpart, /*last assigned partition */
79 float jumplimit, /*new part threshold */
80 float* drift,
81 float* last_delta,
82 int *partcount /*no of partitions */
83 );
84 int partition_coords ( //find relevant coords
85 TBOX blobcoords[], //bounding boxes
86 int blobcount, /*no of blobs in row */
87 char partids[], /*partition no of each blob */
88 int bestpart, /*best new partition */
89 int xcoords[], /*points to work on */
90 int ycoords[] /*points to work on */
91 );
92 int segment_spline ( //make xstarts
93 TBOX blobcoords[], //boundign boxes
94 int blobcount, /*no of blobs in row */
95 int xcoords[], /*points to work on */
96 int ycoords[], /*points to work on */
97 int degree, int pointcount, /*no of points */
98 int xstarts[] //result
99 );
100 bool split_stepped_spline( //make xstarts
101  QSPLINE* baseline, //current shot
102  float jumplimit, //max step function
103  int* xcoords, /*points to work on */
104  int* xstarts, //result
105  int& segments //no of segments
106 );
107 void insert_spline_point ( //get descenders
108 int xstarts[], //starts to shuffle
109 int segment, //insertion pt
110 int coord1, //coords to add
111 int coord2, int &segments //total segments
112 );
113 void find_lesser_parts ( //get descenders
114 TO_ROW * row, //row to process
115 TBOX blobcoords[], //bounding boxes
116 int blobcount, /*no of blobs */
117 char partids[], /*partition of each blob */
118 int partsizes[], /*size of each part */
119 int partcount, /*no of partitions */
120 int bestpart /*biggest partition */
121 );
122 
123 void old_first_xheight ( //the wiseowl way
124 TO_ROW * row, /*current row */
125 TBOX blobcoords[], /*blob bounding boxes */
126 int initialheight, //initial guess
127 int blobcount, /*blobs in blobcoords */
128 QSPLINE * baseline, /*established */
129 float jumplimit /*min ascender height */
130 );
131 
132 void make_first_xheight ( //find xheight
133 TO_ROW * row, /*current row */
134 TBOX blobcoords[], /*blob bounding boxes */
135 int lineheight, //initial guess
136 int init_lineheight, //block level guess
137 int blobcount, /*blobs in blobcoords */
138 QSPLINE * baseline, /*established */
139 float jumplimit /*min ascender height */
140 );
141 
142 int *make_height_array ( //get array of heights
143 TBOX blobcoords[], /*blob bounding boxes */
144 int blobcount, /*blobs in blobcoords */
145 QSPLINE * baseline /*established */
146 );
147 
148 void find_top_modes ( //get modes
149 STATS * stats, //stats to hack
150 int statnum, //no of piles
151 int modelist[], int modenum //no of modes to get
152 );
153 
154 void pick_x_height(TO_ROW * row, //row to do
155 int modelist[],
156 int lefts[], int rights[],
157 STATS * heightstat,
158 int mode_threshold);
159 #endif
choose_partition
int choose_partition(float diff, float partdiffs[], int lastpart, float jumplimit, float *drift, float *last_delta, int *partcount)
Definition: oldbasel.cpp:933
get_ydiffs
int get_ydiffs(TBOX blobcoords[], int blobcount, QSPLINE *spline, float ydiffs[])
Definition: oldbasel.cpp:883
find_lesser_parts
void find_lesser_parts(TO_ROW *row, TBOX blobcoords[], int blobcount, char partids[], int partsizes[], int partcount, int bestpart)
Definition: oldbasel.cpp:1287
baseline
Definition: mfoutline.h:62
blobbox.h
params.h
QSPLINE
Definition: quspline.h:31
partition_coords
int partition_coords(TBOX blobcoords[], int blobcount, char partids[], int bestpart, int xcoords[], int ycoords[])
Definition: oldbasel.cpp:1004
partition_line
int partition_line(TBOX blobcoords[], int blobcount, int *numparts, char partids[], int partsizes[], QSPLINE *spline, float jumplimit, float ydiffs[])
Definition: oldbasel.cpp:691
textord_oldbl_debug
bool textord_oldbl_debug
Definition: oldbasel.cpp:38
insert_spline_point
void insert_spline_point(int xstarts[], int segment, int coord1, int coord2, int &segments)
Definition: oldbasel.cpp:1264
make_first_xheight
void make_first_xheight(TO_ROW *row, TBOX blobcoords[], int lineheight, int init_lineheight, int blobcount, QSPLINE *baseline, float jumplimit)
Definition: oldbasel.cpp:1451
segment_spline
int segment_spline(TBOX blobcoords[], int blobcount, int xcoords[], int ycoords[], int degree, int pointcount, int xstarts[])
Definition: oldbasel.cpp:1034
old_first_xheight
void old_first_xheight(TO_ROW *row, TBOX blobcoords[], int initialheight, int blobcount, QSPLINE *baseline, float jumplimit)
Definition: oldbasel.cpp:1367
get_blob_coords
int get_blob_coords(TO_ROW *row, int32_t lineheight, TBOX *blobcoords, bool &holed_line, int &outcount)
Definition: oldbasel.cpp:423
merge_oldbl_parts
void merge_oldbl_parts(TBOX blobcoords[], int blobcount, char partids[], int partsizes[], int biggestpart, float jumplimit)
Definition: oldbasel.cpp:771
STATS
Definition: statistc.h:30
BOOL_VAR_H
#define BOOL_VAR_H(name, val, comment)
Definition: params.h:294
make_height_array
int * make_height_array(TBOX blobcoords[], int blobcount, QSPLINE *baseline)
split_stepped_spline
bool split_stepped_spline(QSPLINE *baseline, float jumplimit, int *xcoords, int *xstarts, int &segments)
Definition: oldbasel.cpp:1158
pick_x_height
void pick_x_height(TO_ROW *row, int modelist[], int lefts[], int rights[], STATS *heightstat, int mode_threshold)
Definition: oldbasel.cpp:1574
TO_ROW
Definition: blobbox.h:543
make_holed_baseline
void make_holed_baseline(TBOX blobcoords[], int blobcount, QSPLINE *spline, QSPLINE *baseline, float gradient)
Definition: oldbasel.cpp:634
make_first_baseline
void make_first_baseline(TBOX blobcoords[], int blobcount, int xcoords[], int ycoords[], QSPLINE *spline, QSPLINE *baseline, float jumplimit)
Definition: oldbasel.cpp:492
find_top_modes
void find_top_modes(STATS *stats, int statnum, int modelist[], int modenum)
Definition: oldbasel.cpp:1535
TBOX
Definition: rect.h:33