tesseract  v4.0.0-17-g361f3264
Open Source OCR Engine
mfoutline.h
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 
19 #ifndef MFOUTLINE_H
20 #define MFOUTLINE_H
21 
25 #include "blobs.h"
26 #include "host.h"
27 #include "oldlist.h"
28 #include "fpoint.h"
29 #include "params.h"
30 
31 #define NORMAL_X_HEIGHT (0.5)
32 #define NORMAL_BASELINE (0.0)
33 
34 typedef LIST MFOUTLINE;
35 
36 typedef enum {
37  north, south, east, west, northeast, northwest, southeast, southwest
38 } DIRECTION;
39 
40 typedef struct {
42  float Slope;
43  unsigned Padding:20;
44  BOOL8 Hidden:TRUE;
45  BOOL8 ExtremityMark:TRUE;
46  DIRECTION Direction:4;
47  DIRECTION PreviousDirection:4;
48 } MFEDGEPT;
49 
50 typedef enum {
51  outer, hole
52 } OUTLINETYPE;
53 
54 typedef enum {
55  baseline, character
56 } NORM_METHOD;
57 
61 #define AverageOf(A,B) (((A) + (B)) / 2)
62 
63 /* macro for computing the scale factor to use to normalize characters */
64 #define MF_SCALE_FACTOR (NORMAL_X_HEIGHT / kBlnXHeight)
65 
66 /* macros for manipulating micro-feature outlines */
67 #define DegenerateOutline(O) (((O) == NIL_LIST) || ((O) == list_rest(O)))
68 #define PointAt(O) ((MFEDGEPT *) first_node (O))
69 #define NextPointAfter(E) (list_rest (E))
70 #define MakeOutlineCircular(O) (set_rest (last (O), (O)))
71 
72 /* macros for manipulating micro-feature outline edge points */
73 #define ClearMark(P) ((P)->ExtremityMark = FALSE)
74 #define MarkPoint(P) ((P)->ExtremityMark = TRUE)
75 
79 void ComputeBlobCenter(TBLOB *Blob, TPOINT *BlobCenter);
80 
81 LIST ConvertBlob(TBLOB *Blob);
82 
83 MFOUTLINE ConvertOutline(TESSLINE *Outline);
84 
85 LIST ConvertOutlines(TESSLINE *Outline,
86  LIST ConvertedOutlines,
87  OUTLINETYPE OutlineType);
88 
89 void FilterEdgeNoise(MFOUTLINE Outline, float NoiseSegmentLength);
90 
91 void FindDirectionChanges(MFOUTLINE Outline,
92  float MinSlope,
93  float MaxSlope);
94 
95 void FreeMFOutline(void *agr); //MFOUTLINE Outline);
96 
97 void FreeOutlines(LIST Outlines);
98 
99 void MarkDirectionChanges(MFOUTLINE Outline);
100 
101 MFEDGEPT *NewEdgePoint();
102 
103 MFOUTLINE NextExtremity(MFOUTLINE EdgePoint);
104 
105 void NormalizeOutline(MFOUTLINE Outline,
106  float XOrigin);
107 
108 /*----------------------------------------------------------------------------
109  Private Function Prototypes
110 -----------------------------------------------------------------------------*/
111 void ChangeDirection(MFOUTLINE Start, MFOUTLINE End, DIRECTION Direction);
112 
113 // Normalizes the Outline in-place using cn_denorm's local transformation,
114 // then converts from the integer feature range [0,255] to the clusterer
115 // feature range of [-0.5, 0.5].
116 void CharNormalizeOutline(MFOUTLINE Outline, const DENORM& cn_denorm);
117 
118 void ComputeDirection(MFEDGEPT *Start,
119  MFEDGEPT *Finish,
120  float MinSlope,
121  float MaxSlope);
122 
123 MFOUTLINE NextDirectionChange(MFOUTLINE EdgePoint);
124 
125 #endif
BOOL8 Hidden
Definition: mfoutline.h:44
BOOL8 ExtremityMark
Definition: mfoutline.h:45
FPOINT Point
Definition: mfoutline.h:41
Definition: fpoint.h:30
Definition: blobs.h:187
DIRECTION Direction
Definition: mfoutline.h:46
DIRECTION PreviousDirection
Definition: mfoutline.h:47
Definition: mfoutline.h:40
Definition: normalis.h:50
Definition: oldlist.h:124
float Slope
Definition: mfoutline.h:42
Definition: blobs.h:268
unsigned Padding
Definition: mfoutline.h:43
Definition: blobs.h:57