tesseract  4.1.0
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  **
6  ** (c) Copyright Hewlett-Packard Company, 1988.
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 #ifndef MFOUTLINE_H
19 #define MFOUTLINE_H
20 
24 #include "blobs.h"
25 #include "fpoint.h"
26 #include "oldlist.h"
27 #include "params.h"
28 
29 #define NORMAL_X_HEIGHT (0.5)
30 #define NORMAL_BASELINE (0.0)
31 
32 using MFOUTLINE = LIST;
33 
34 typedef enum {
43 } DIRECTION;
44 
45 typedef struct {
47  float Slope;
48  unsigned Padding : 20;
49  bool Hidden : true;
50  bool ExtremityMark : true;
51  DIRECTION Direction : 4;
52  DIRECTION PreviousDirection : 4;
53 } MFEDGEPT;
54 
55 typedef enum { outer, hole } OUTLINETYPE;
56 
57 typedef enum { baseline, character } NORM_METHOD;
58 
62 #define AverageOf(A, B) (((A) + (B)) / 2)
63 
64 /* macro for computing the scale factor to use to normalize characters */
65 #define MF_SCALE_FACTOR (NORMAL_X_HEIGHT / kBlnXHeight)
66 
67 /* macros for manipulating micro-feature outlines */
68 #define DegenerateOutline(O) (((O) == NIL_LIST) || ((O) == list_rest(O)))
69 #define PointAt(O) ((MFEDGEPT*)first_node(O))
70 #define NextPointAfter(E) (list_rest(E))
71 #define MakeOutlineCircular(O) (set_rest(last(O), (O)))
72 
73 /* macros for manipulating micro-feature outline edge points */
74 #define ClearMark(P) ((P)->ExtremityMark = false)
75 #define MarkPoint(P) ((P)->ExtremityMark = true)
76 
80 void ComputeBlobCenter(TBLOB* Blob, TPOINT* BlobCenter);
81 
82 LIST ConvertBlob(TBLOB* Blob);
83 
85 
86 LIST ConvertOutlines(TESSLINE* Outline, LIST ConvertedOutlines,
87  OUTLINETYPE OutlineType);
88 
89 void FilterEdgeNoise(MFOUTLINE Outline, float NoiseSegmentLength);
90 
91 void FindDirectionChanges(MFOUTLINE Outline, float MinSlope, float MaxSlope);
92 
93 void FreeMFOutline(void* agr); // MFOUTLINE Outline);
94 
95 void FreeOutlines(LIST Outlines);
96 
97 void MarkDirectionChanges(MFOUTLINE Outline);
98 
100 
102 
103 void NormalizeOutline(MFOUTLINE Outline, float XOrigin);
104 
105 /*----------------------------------------------------------------------------
106  Private Function Prototypes
107 -----------------------------------------------------------------------------*/
108 void ChangeDirection(MFOUTLINE Start, MFOUTLINE End, DIRECTION Direction);
109 
110 // Normalizes the Outline in-place using cn_denorm's local transformation,
111 // then converts from the integer feature range [0,255] to the clusterer
112 // feature range of [-0.5, 0.5].
113 void CharNormalizeOutline(MFOUTLINE Outline, const DENORM& cn_denorm);
114 
115 void ComputeDirection(MFEDGEPT* Start, MFEDGEPT* Finish, float MinSlope,
116  float MaxSlope);
117 
119 
120 #endif
LIST ConvertBlob(TBLOB *Blob)
Definition: mfoutline.cpp:37
void FreeOutlines(LIST Outlines)
Definition: mfoutline.cpp:167
void ComputeBlobCenter(TBLOB *Blob, TPOINT *BlobCenter)
OUTLINETYPE
Definition: mfoutline.h:55
Definition: mfoutline.h:38
Definition: mfoutline.h:37
Definition: blobs.h:263
void FindDirectionChanges(MFOUTLINE Outline, float MinSlope, float MaxSlope)
Definition: mfoutline.cpp:115
list_rec * LIST
Definition: oldlist.h:85
void MarkDirectionChanges(MFOUTLINE Outline)
Definition: mfoutline.cpp:183
void FilterEdgeNoise(MFOUTLINE Outline, float NoiseSegmentLength)
void FreeMFOutline(void *agr)
Definition: mfoutline.cpp:146
Definition: blobs.h:52
MFOUTLINE NextExtremity(MFOUTLINE EdgePoint)
Definition: mfoutline.cpp:220
MFOUTLINE ConvertOutline(TESSLINE *Outline)
Definition: mfoutline.cpp:47
void ChangeDirection(MFOUTLINE Start, MFOUTLINE End, DIRECTION Direction)
Definition: mfoutline.cpp:309
DIRECTION
Definition: mfoutline.h:34
void ComputeDirection(MFEDGEPT *Start, MFEDGEPT *Finish, float MinSlope, float MaxSlope)
Definition: mfoutline.cpp:363
FPOINT Point
Definition: mfoutline.h:46
NORM_METHOD
Definition: mfoutline.h:57
MFEDGEPT * NewEdgePoint()
Definition: mfoutline.cpp:205
void NormalizeOutline(MFOUTLINE Outline, float XOrigin)
Definition: mfoutline.cpp:242
Definition: mfoutline.h:55
LIST ConvertOutlines(TESSLINE *Outline, LIST ConvertedOutlines, OUTLINETYPE OutlineType)
Definition: mfoutline.cpp:89
MFOUTLINE NextDirectionChange(MFOUTLINE EdgePoint)
Definition: mfoutline.cpp:434
float Slope
Definition: mfoutline.h:47
Definition: fpoint.h:29
void CharNormalizeOutline(MFOUTLINE Outline, const DENORM &cn_denorm)
Definition: mfoutline.cpp:326