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
blkocc.h
Go to the documentation of this file.
1
/******************************************************************************
2
*
3
* File: blkocc.h (Formerly blockocc.h)
4
* Description: Block Occupancy routines
5
* Author: Chris Newton
6
* Created: Fri Nov 8
7
* Modified:
8
* Language: C++
9
* Package: N/A
10
* Status: Experimental (Do Not Distribute)
11
*
12
* (c) Copyright 1991, Hewlett-Packard Company.
13
** Licensed under the Apache License, Version 2.0 (the "License");
14
** you may not use this file except in compliance with the License.
15
** You may obtain a copy of the License at
16
** http://www.apache.org/licenses/LICENSE-2.0
17
** Unless required by applicable law or agreed to in writing, software
18
** distributed under the License is distributed on an "AS IS" BASIS,
19
** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
20
** See the License for the specific language governing permissions and
21
** limitations under the License.
22
*
23
******************************************************************************/
24
25
#ifndef BLKOCC_H
26
#define BLKOCC_H
27
28
#include "
params.h
"
29
#include "
elst.h
"
30
#include "
notdll.h
"
31
#include "
notdll.h
"
32
33
/***************************************************************************
34
CLASS REGION_OCC
35
36
The class REGION_OCC defines a section of outline which exists entirely
37
within a single region. The only data held is the min and max x limits of
38
the outline within the region.
39
40
REGION_OCCs are held on lists, one list for each region. The lists are
41
built in sorted order of min x. Overlapping REGION_OCCs are not permitted on
42
a single list. An overlapping region to be added causes the existing region
43
to be extended. This extension may result in the following REGION_OCC on the
44
list overlapping the ammended one. In this case the ammended REGION_OCC is
45
further extended to include the range of the following one, so that the
46
following one can be deleted.
47
48
****************************************************************************/
49
50
class
REGION_OCC
:
public
ELIST_LINK
51
{
52
public
:
53
float
min_x
;
//Lowest x in region
54
float
max_x
;
//Highest x in region
55
inT16
region_type
;
//Type of crossing
56
57
REGION_OCC
() {
58
};
//constructor used
59
//only in COPIER etc
60
REGION_OCC
(
//constructor
61
float
min,
62
float
max,
63
inT16
region) {
64
min_x
= min;
65
max_x
= max;
66
region_type
= region;
67
}
68
};
69
70
ELISTIZEH
(
REGION_OCC
)
71
#define RANGE_IN_BAND( band_max, band_min, range_max, range_min ) \
72
( ((range_min) >= (band_min)) && ((range_max) < (band_max)) ) ? TRUE : FALSE
73
/************************************************************************
74
Adapted from the following procedure so that it can be used in the bands
75
class in an include file...
76
77
BOOL8 range_in_band[
78
range within band?
79
inT16 band_max,
80
inT16 band_min,
81
inT16 range_max,
82
inT16 range_min]
83
{
84
if ( (range_min >= band_min) && (range_max < band_max) )
85
return TRUE;
86
else
87
return FALSE;
88
}
89
***********************************************************************/
90
#define RANGE_OVERLAPS_BAND( band_max, band_min, range_max, range_min ) \
91
( ((range_max) >= (band_min)) && ((range_min) < (band_max)) ) ? TRUE : FALSE
92
/************************************************************************
93
Adapted from the following procedure so that it can be used in the bands
94
class in an include file...
95
96
BOOL8 range_overlaps_band[
97
range crosses band?
98
inT16 band_max,
99
inT16 band_min,
100
inT16 range_max,
101
inT16 range_min]
102
{
103
if ( (range_max >= band_min) && (range_min < band_max) )
104
return TRUE;
105
else
106
return FALSE;
107
}
108
***********************************************************************/
109
/**********************************************************************
110
Bands
111
-----
112
113
BAND 4
114
--------------------------------
115
BAND 3
116
--------------------------------
117
118
BAND 2
119
120
--------------------------------
121
122
BAND 1
123
124
Band 0 is the dot band
125
126
Each band has an error margin above and below. An outline is not considered to
127
have significantly changed bands until it has moved out of the error margin.
128
*************************************************************************/
129
class
BAND
130
{
131
public
:
132
inT16
max_max
;
//upper max
133
inT16
max
;
//nominal max
134
inT16
min_max
;
//lower max
135
inT16
max_min
;
//upper min
136
inT16
min
;
//nominal min
137
inT16
min_min
;
//lower min
138
139
BAND
() {
140
}
// constructor
141
142
void
set
(
// initialise a band
143
inT16
new_max_max,
// upper max
144
inT16
new_max,
// new nominal max
145
inT16
new_min_max,
// new lower max
146
inT16
new_max_min,
// new upper min
147
inT16
new_min,
// new nominal min
148
inT16
new_min_min) {
// new lower min
149
max_max
= new_max_max;
150
max
= new_max;
151
min_max
= new_min_max;
152
max_min
= new_max_min;
153
min
= new_min;
154
min_min
= new_min_min;
155
}
156
157
BOOL8
in_minimal
(
//in minimal limits?
158
float
y) {
//y value
159
if
((y >=
max_min
) && (y <
min_max
))
160
return
TRUE
;
161
else
162
return
FALSE
;
163
}
164
165
BOOL8
in_nominal
(
//in nominal limits?
166
float
y) {
//y value
167
if
((y >=
min
) && (y <
max
))
168
return
TRUE
;
169
else
170
return
FALSE
;
171
}
172
173
BOOL8
in_maximal
(
//in maximal limits?
174
float
y) {
//y value
175
if
((y >=
min_min
) && (y <
max_max
))
176
return
TRUE
;
177
else
178
return
FALSE
;
179
}
180
181
//overlaps min limits?
182
BOOL8
range_overlaps_minimal
(
float
y1,
//one range limit
183
float
y2) {
//other range limit
184
if
(y1 > y2)
185
return
RANGE_OVERLAPS_BAND
(
min_max
,
max_min
, y1, y2);
186
else
187
return
RANGE_OVERLAPS_BAND
(
min_max
,
max_min
, y2, y1);
188
}
189
190
//overlaps nom limits?
191
BOOL8
range_overlaps_nominal
(
float
y1,
//one range limit
192
float
y2) {
//other range limit
193
if
(y1 > y2)
194
return
RANGE_OVERLAPS_BAND
(
max
,
min
, y1, y2);
195
else
196
return
RANGE_OVERLAPS_BAND
(
max
,
min
, y2, y1);
197
}
198
199
//overlaps max limits?
200
BOOL8
range_overlaps_maximal
(
float
y1,
//one range limit
201
float
y2) {
//other range limit
202
if
(y1 > y2)
203
return
RANGE_OVERLAPS_BAND
(
max_max
,
min_min
, y1, y2);
204
else
205
return
RANGE_OVERLAPS_BAND
(
max_max
,
min_min
, y2, y1);
206
}
207
208
BOOL8
range_in_minimal
(
//within min limits?
209
float
y1,
//one range limit
210
float
y2) {
//other range limit
211
if
(y1 > y2)
212
return
RANGE_IN_BAND
(
min_max
,
max_min
, y1, y2);
213
else
214
return
RANGE_IN_BAND
(
min_max
,
max_min
, y2, y1);
215
}
216
217
BOOL8
range_in_nominal
(
//within nom limits?
218
float
y1,
//one range limit
219
float
y2) {
//other range limit
220
if
(y1 > y2)
221
return
RANGE_IN_BAND
(
max
,
min
, y1, y2);
222
else
223
return
RANGE_IN_BAND
(
max
,
min
, y2, y1);
224
}
225
226
BOOL8
range_in_maximal
(
//within max limits?
227
float
y1,
//one range limit
228
float
y2) {
//other range limit
229
if
(y1 > y2)
230
return
RANGE_IN_BAND
(
max_max
,
min_min
, y1, y2);
231
else
232
return
RANGE_IN_BAND
(
max_max
,
min_min
, y2, y1);
233
}
234
};
235
236
/* Standard positions */
237
238
#define MAX_NUM_BANDS 5
239
#define UNDEFINED_BAND 99
240
#define NO_LOWER_LIMIT -9999
241
#define NO_UPPER_LIMIT 9999
242
243
#define DOT_BAND 0
244
245
/* Special occupancy code emitted for the 0 region at the end of a word */
246
247
#define END_OF_WERD_CODE 255
248
249
extern
BOOL_VAR_H
(blockocc_show_result,
FALSE
,
"Show intermediate results"
);
250
extern
INT_VAR_H
(blockocc_desc_height, 0,
251
"Descender height after normalisation"
);
252
extern
INT_VAR_H
(blockocc_asc_height, 255,
253
"Ascender height after normalisation"
);
254
extern
INT_VAR_H
(blockocc_band_count, 4,
"Number of bands used"
);
255
extern
double_VAR_H
(
textord_underline_threshold
, 0.9,
256
"Fraction of width occupied"
);
257
258
BOOL8
test_underline
(
//look for underlines
259
BOOL8
testing_on,
//drawing blob
260
C_BLOB
*blob,
//blob to test
261
inT16
baseline
,
//coords of baseline
262
inT16
xheight
//height of line
263
);
264
265
#endif
mnt
data
src
tesseract-ocr
textord
blkocc.h
Generated on Thu Nov 1 2012 20:19:49 for Tesseract by
1.8.1