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