tesseract  5.0.0-alpha-619-ge9db
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 using MFOUTLINE = LIST;
30 
31 enum DIRECTION : uint8_t {
39  southwest
40 };
41 
42 struct MFEDGEPT {
43  // Inline functions for manipulating micro-feature outline edge points.
44 
45  void ClearMark() {
46  ExtremityMark = false;
47  }
48 
49  void MarkPoint() {
50  ExtremityMark = true;
51  }
52 
54  float Slope;
55  bool Hidden;
59 };
60 
61 enum OUTLINETYPE { outer, hole };
62 
64 
68 #define AverageOf(A, B) (((A) + (B)) / 2)
69 
70 // Constant for computing the scale factor to use to normalize characters.
71 const float MF_SCALE_FACTOR = 0.5f / kBlnXHeight;
72 
73 // Inline functions for manipulating micro-feature outlines.
74 
75 static inline bool DegenerateOutline(MFOUTLINE Outline) {
76  return (Outline == NIL_LIST) || (Outline == list_rest(Outline));
77 }
78 
79 static inline MFEDGEPT* PointAt(MFOUTLINE Outline) {
80  return reinterpret_cast<MFEDGEPT*>first_node(Outline);
81 }
82 
83 static inline MFOUTLINE NextPointAfter(MFOUTLINE Outline) {
84  return list_rest(Outline);
85 }
86 
87 static inline void MakeOutlineCircular(MFOUTLINE Outline) {
88  set_rest(last(Outline), Outline);
89 }
90 
94 void ComputeBlobCenter(TBLOB* Blob, TPOINT* BlobCenter);
95 
96 LIST ConvertBlob(TBLOB* Blob);
97 
99 
100 LIST ConvertOutlines(TESSLINE* Outline, LIST ConvertedOutlines,
101  OUTLINETYPE OutlineType);
102 
103 void FilterEdgeNoise(MFOUTLINE Outline, float NoiseSegmentLength);
104 
105 void FindDirectionChanges(MFOUTLINE Outline, float MinSlope, float MaxSlope);
106 
107 void FreeMFOutline(void* agr); // MFOUTLINE Outline);
108 
109 void FreeOutlines(LIST Outlines);
110 
111 void MarkDirectionChanges(MFOUTLINE Outline);
112 
114 
116 
117 void NormalizeOutline(MFOUTLINE Outline, float XOrigin);
118 
119 /*----------------------------------------------------------------------------
120  Private Function Prototypes
121 -----------------------------------------------------------------------------*/
122 void ChangeDirection(MFOUTLINE Start, MFOUTLINE End, DIRECTION Direction);
123 
124 // Normalizes the Outline in-place using cn_denorm's local transformation,
125 // then converts from the integer feature range [0,255] to the clusterer
126 // feature range of [-0.5, 0.5].
127 void CharNormalizeOutline(MFOUTLINE Outline, const DENORM& cn_denorm);
128 
129 void ComputeDirection(MFEDGEPT* Start, MFEDGEPT* Finish, float MinSlope,
130  float MaxSlope);
131 
133 
134 #endif
MFEDGEPT::Direction
DIRECTION Direction
Definition: mfoutline.h:56
DIRECTION
DIRECTION
Definition: mfoutline.h:30
ComputeDirection
void ComputeDirection(MFEDGEPT *Start, MFEDGEPT *Finish, float MinSlope, float MaxSlope)
Definition: mfoutline.cpp:363
ChangeDirection
void ChangeDirection(MFOUTLINE Start, MFOUTLINE End, DIRECTION Direction)
Definition: mfoutline.cpp:309
south
Definition: mfoutline.h:32
MFEDGEPT::Hidden
bool Hidden
Definition: mfoutline.h:54
MFEDGEPT::Point
FPOINT Point
Definition: mfoutline.h:52
ConvertOutline
MFOUTLINE ConvertOutline(TESSLINE *Outline)
Definition: mfoutline.cpp:46
fpoint.h
kBlnXHeight
const int kBlnXHeight
Definition: normalis.h:23
TPOINT
Definition: blobs.h:49
first_node
#define first_node(l)
Definition: oldlist.h:84
MFEDGEPT::ExtremityMark
bool ExtremityMark
Definition: mfoutline.h:55
list_rec
Definition: oldlist.h:73
list_rest
#define list_rest(l)
Definition: oldlist.h:83
baseline
Definition: mfoutline.h:62
params.h
TESSLINE
Definition: blobs.h:201
FPOINT
Definition: fpoint.h:28
northwest
Definition: mfoutline.h:36
ConvertBlob
LIST ConvertBlob(TBLOB *Blob)
Definition: mfoutline.cpp:36
FilterEdgeNoise
void FilterEdgeNoise(MFOUTLINE Outline, float NoiseSegmentLength)
MFEDGEPT::PreviousDirection
DIRECTION PreviousDirection
Definition: mfoutline.h:57
MF_SCALE_FACTOR
const float MF_SCALE_FACTOR
Definition: mfoutline.h:70
NIL_LIST
#define NIL_LIST
Definition: oldlist.h:68
blobs.h
oldlist.h
southwest
Definition: mfoutline.h:38
OUTLINETYPE
OUTLINETYPE
Definition: mfoutline.h:60
LIST
list_rec * LIST
Definition: oldlist.h:77
last
LIST last(LIST var_list)
Definition: oldlist.cpp:151
CharNormalizeOutline
void CharNormalizeOutline(MFOUTLINE Outline, const DENORM &cn_denorm)
Definition: mfoutline.cpp:326
ComputeBlobCenter
void ComputeBlobCenter(TBLOB *Blob, TPOINT *BlobCenter)
NORM_METHOD
NORM_METHOD
Definition: mfoutline.h:62
character
Definition: mfoutline.h:62
MFEDGEPT::MarkPoint
void MarkPoint()
Definition: mfoutline.h:48
ConvertOutlines
LIST ConvertOutlines(TESSLINE *Outline, LIST ConvertedOutlines, OUTLINETYPE OutlineType)
Definition: mfoutline.cpp:88
southeast
Definition: mfoutline.h:37
MFEDGEPT::Slope
float Slope
Definition: mfoutline.h:53
TBLOB
Definition: blobs.h:282
MFEDGEPT::ClearMark
void ClearMark()
Definition: mfoutline.h:44
NextDirectionChange
MFOUTLINE NextDirectionChange(MFOUTLINE EdgePoint)
Definition: mfoutline.cpp:434
MFEDGEPT
Definition: mfoutline.h:41
NormalizeOutline
void NormalizeOutline(MFOUTLINE Outline, float XOrigin)
Definition: mfoutline.cpp:241
east
Definition: mfoutline.h:33
west
Definition: mfoutline.h:34
north
Definition: mfoutline.h:31
NewEdgePoint
MFEDGEPT * NewEdgePoint()
Definition: mfoutline.cpp:204
hole
Definition: mfoutline.h:60
NextExtremity
MFOUTLINE NextExtremity(MFOUTLINE EdgePoint)
Definition: mfoutline.cpp:219
FindDirectionChanges
void FindDirectionChanges(MFOUTLINE Outline, float MinSlope, float MaxSlope)
Definition: mfoutline.cpp:114
northeast
Definition: mfoutline.h:35
MarkDirectionChanges
void MarkDirectionChanges(MFOUTLINE Outline)
Definition: mfoutline.cpp:182
outer
Definition: mfoutline.h:60
set_rest
#define set_rest(l, cell)
Definition: oldlist.h:101
FreeMFOutline
void FreeMFOutline(void *agr)
Definition: mfoutline.cpp:145
FreeOutlines
void FreeOutlines(LIST Outlines)
Definition: mfoutline.cpp:166
DENORM
Definition: normalis.h:49