Tesseract  3.02
 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 
28 "Use original wiseowl xheight");
30 "Debug old baseline generation");
32 "Debug baseline generation");
33 extern BOOL_VAR_H (textord_oldbl_paradef, TRUE, "Use para default mechanism");
35 "Split stepped splines");
37 "Merge suspect partitions");
39 "Fix bug in modes threshold for xheights");
41 "Max lost before fallback line used");
42 extern double_VAR_H (oldbl_dot_error_size, 1.26, "Max aspect ratio of a dot");
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
void make_holed_baseline(TBOX blobcoords[], int blobcount, QSPLINE *spline, QSPLINE *baseline, float gradient)
Definition: oldbasel.cpp:660
#define BOOL_VAR_H(name, val, comment)
Definition: params.h:239
unsigned char BOOL8
Definition: host.h:113
int oldbl_holed_losscount
Definition: oldbasel.cpp:51
bool textord_oldbl_merge_parts
Definition: oldbasel.cpp:44
double textord_oldbl_jumplimit
Definition: oldbasel.cpp:54
int inT32
Definition: host.h:102
Definition: rect.h:29
int get_ydiffs(TBOX blobcoords[], int blobcount, QSPLINE *spline, float ydiffs[])
Definition: oldbasel.cpp:912
#define FALSE
Definition: capi.h:28
int segment_spline(TBOX blobcoords[], int blobcount, int xcoords[], int ycoords[], int degree, int pointcount, int xstarts[])
Definition: oldbasel.cpp:1121
double oldbl_dot_error_size
Definition: oldbasel.cpp:52
void insert_spline_point(int xstarts[], int segment, int coord1, int coord2, int &segments)
Definition: oldbasel.cpp:1353
int choose_partition(register float diff, float partdiffs[], int lastpart, float jumplimit, float *drift, float *last_delta, int *partcount)
Definition: oldbasel.cpp:963
bool textord_oldbl_debug
Definition: oldbasel.cpp:40
#define double_VAR_H(name, val, comment)
Definition: params.h:245
BOOL8 split_stepped_spline(QSPLINE *baseline, float jumplimit, int xcoords[], int xstarts[], int &segments)
Definition: oldbasel.cpp:1246
bool textord_debug_baselines
Definition: oldbasel.cpp:41
void make_first_xheight(TO_ROW *row, TBOX blobcoords[], int lineheight, int init_lineheight, int blobcount, QSPLINE *baseline, float jumplimit)
Definition: oldbasel.cpp:1547
bool textord_really_old_xheight
Definition: oldbasel.cpp:39
bool oldbl_xhfix
Definition: oldbasel.cpp:47
void old_first_xheight(TO_ROW *row, TBOX blobcoords[], int initialheight, int blobcount, QSPLINE *baseline, float jumplimit)
Definition: oldbasel.cpp:1462
bool textord_oldbl_paradef
Definition: oldbasel.cpp:42
void merge_oldbl_parts(TBOX blobcoords[], int blobcount, char partids[], int partsizes[], int biggestpart, float jumplimit)
Definition: oldbasel.cpp:799
int * make_height_array(TBOX blobcoords[], int blobcount, QSPLINE *baseline)
Definition: statistc.h:29
void find_top_modes(STATS *stats, int statnum, int modelist[], int modenum)
Definition: oldbasel.cpp:1632
bool textord_oldbl_split_splines
Definition: oldbasel.cpp:43
int get_blob_coords(TO_ROW *row, inT32 lineheight, TBOX *blobcoords, BOOL8 &holed_line, int &outcount)
Definition: oldbasel.cpp:447
#define INT_VAR_H(name, val, comment)
Definition: params.h:236
void make_first_baseline(TBOX blobcoords[], int blobcount, int xcoords[], int ycoords[], QSPLINE *spline, QSPLINE *baseline, float jumplimit)
Definition: oldbasel.cpp:517
void find_lesser_parts(TO_ROW *row, TBOX blobcoords[], int blobcount, char partids[], int partsizes[], int partcount, int bestpart)
Definition: oldbasel.cpp:1377
void pick_x_height(TO_ROW *row, int modelist[], int lefts[], int rights[], STATS *heightstat, int mode_threshold)
Definition: oldbasel.cpp:1672
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:1090
int partition_line(TBOX blobcoords[], int blobcount, int *numparts, char partids[], int partsizes[], QSPLINE *spline, float jumplimit, float ydiffs[])
Definition: oldbasel.cpp:718
#define TRUE
Definition: capi.h:27