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
mfoutline.h
Go to the documentation of this file.
1 /******************************************************************************
2 ** Filename: mfoutline.h
3 ** Purpose: Interface spec for fx outline structures
4 ** Author: Dan Johnson
5 ** History: Thu May 17 08:55:32 1990, DSJ, Created.
6 **
7 ** (c) Copyright Hewlett-Packard Company, 1988.
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 #ifndef MFOUTLINE_H
19 #define MFOUTLINE_H
20
24 #include "host.h"
25 #include "oldlist.h"
26 #include "fpoint.h"
27 #include "baseline.h"
28 #include "params.h"
29
30 #define NORMAL_X_HEIGHT (0.5)
31 #define NORMAL_BASELINE (0.0)
32
33 typedef LIST MFOUTLINE;
34
35 typedef enum {
36 north, south, east, west, northeast, northwest, southeast, southwest
37 } DIRECTION;
38
39 typedef struct {
40 FPOINT Point;
41 FLOAT32 Slope;
42 unsigned Padding:20;
43 BOOL8 Hidden:TRUE;
44 BOOL8 ExtremityMark:TRUE;
45 DIRECTION Direction:4;
46 DIRECTION PreviousDirection:4;
47 } MFEDGEPT;
48
49 typedef enum {
50 outer, hole
51 } OUTLINETYPE;
52
53 typedef struct {
54 FLOAT64 Mx, My; /* first moment of all outlines */
55 FLOAT64 L; /* total length of all outlines */
56 FLOAT64 x, y; /* center of mass of all outlines */
57 FLOAT64 Ix, Iy; /* second moments about center of mass axes */
58 FLOAT64 Rx, Ry; /* radius of gyration about center of mass axes */
59 } OUTLINE_STATS;
60
61 typedef enum {
62 baseline, character
63 } NORM_METHOD;
64
68 #define AverageOf(A,B) (((A) + (B)) / 2)
69
70 /* macro for computing the scale factor to use to normalize characters */
71 #define MF_SCALE_FACTOR (NORMAL_X_HEIGHT / BASELINE_SCALE)
72
73 /* macros for manipulating micro-feature outlines */
74 #define DegenerateOutline(O) (((O) == NIL_LIST) || ((O) == list_rest(O)))
75 #define PointAt(O) ((MFEDGEPT *) first_node (O))
76 #define NextPointAfter(E) (list_rest (E))
77 #define MakeOutlineCircular(O) (set_rest (last (O), (O)))
78
79 /* macros for manipulating micro-feature outline edge points */
80 #define ClearMark(P) ((P)->ExtremityMark = FALSE)
81 #define MarkPoint(P) ((P)->ExtremityMark = TRUE)
82
86 void ComputeBlobCenter(TBLOB *Blob, TPOINT *BlobCenter);
87
88 LIST ConvertBlob(TBLOB *Blob);
89
90 MFOUTLINE ConvertOutline(TESSLINE *Outline);
91
92 LIST ConvertOutlines(TESSLINE *Outline,
93 LIST ConvertedOutlines,
94 OUTLINETYPE OutlineType);
95
96 void ComputeOutlineStats(LIST Outlines, OUTLINE_STATS *OutlineStats);
97
98 void FilterEdgeNoise(MFOUTLINE Outline, FLOAT32 NoiseSegmentLength);
99
100 void FindDirectionChanges(MFOUTLINE Outline,
101 FLOAT32 MinSlope,
102 FLOAT32 MaxSlope);
103
104 void FreeMFOutline(void *agr); //MFOUTLINE Outline);
105
106 void FreeOutlines(LIST Outlines);
107
108 void MarkDirectionChanges(MFOUTLINE Outline);
109
110 MFEDGEPT *NewEdgePoint();
111
112 MFOUTLINE NextExtremity(MFOUTLINE EdgePoint);
113
114 void NormalizeOutline(MFOUTLINE Outline,
115 FLOAT32 XOrigin);
116
117 /*----------------------------------------------------------------------------
118 Private Function Prototypes
119 -----------------------------------------------------------------------------*/
120 void ChangeDirection(MFOUTLINE Start, MFOUTLINE End, DIRECTION Direction);
121
122 void CharNormalizeOutline(MFOUTLINE Outline,
123 FLOAT32 XCenter,
124 FLOAT32 YCenter,
125 FLOAT32 XScale,
126 FLOAT32 YScale);
127
128 void ComputeDirection(MFEDGEPT *Start,
129 MFEDGEPT *Finish,
130 FLOAT32 MinSlope,
131 FLOAT32 MaxSlope);
132
133 void FinishOutlineStats(register OUTLINE_STATS *OutlineStats);
134
135 void InitOutlineStats(OUTLINE_STATS *OutlineStats);
136
137 MFOUTLINE NextDirectionChange(MFOUTLINE EdgePoint);
138
139 void UpdateOutlineStats(register OUTLINE_STATS *OutlineStats,
140 register FLOAT32 x1,
141 register FLOAT32 x2,
142 register FLOAT32 y1,
143 register FLOAT32 y2);
144
145 #endif