tesseract 4.1.1
Loading...
Searching...
No Matches
mfx.cpp
Go to the documentation of this file.
1/******************************************************************************
2 ** Filename: mfx.c
3 ** Purpose: Micro feature extraction routines
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 Include Files and Type Defines
19----------------------------------------------------------------------------*/
20
21#include "mfx.h"
22#include "mfdefs.h"
23#include "mfoutline.h"
24#include "clusttool.h" //NEEDED
25#include "intfx.h"
26#include "normalis.h"
27#include "params.h"
28
29/*----------------------------------------------------------------------------
30 Variables
31----------------------------------------------------------------------------*/
32
33/* old numbers corresponded to 10.0 degrees and 80.0 degrees */
35 "Slope below which lines are called horizontal");
37 "Slope above which lines are called vertical");
38
39/*----------------------------------------------------------------------------
40 Private Function Prototypes
41-----------------------------------------------------------------------------*/
42
44 MICROFEATURES MicroFeatures);
45
47
48/*----------------------------------------------------------------------------
49 Public Code
50----------------------------------------------------------------------------*/
51
61MICROFEATURES BlobMicroFeatures(TBLOB* Blob, const DENORM& cn_denorm) {
62 MICROFEATURES MicroFeatures = NIL_LIST;
63 LIST Outlines;
64 LIST RemainingOutlines;
65 MFOUTLINE Outline;
66
67 if (Blob != nullptr) {
68 Outlines = ConvertBlob(Blob);
69
70 RemainingOutlines = Outlines;
71 iterate(RemainingOutlines) {
72 Outline = static_cast<MFOUTLINE>first_node (RemainingOutlines);
73 CharNormalizeOutline(Outline, cn_denorm);
74 }
75
76 RemainingOutlines = Outlines;
77 iterate(RemainingOutlines) {
78 Outline = static_cast<MFOUTLINE>first_node(RemainingOutlines);
80 MarkDirectionChanges(Outline);
81 MicroFeatures = ConvertToMicroFeatures(Outline, MicroFeatures);
82 }
83 FreeOutlines(Outlines);
84 }
85 return MicroFeatures;
86} /* BlobMicroFeatures */
87
88/*---------------------------------------------------------------------------
89 Private Code
90---------------------------------------------------------------------------*/
91
100 MICROFEATURES MicroFeatures) {
101 MFOUTLINE Current;
102 MFOUTLINE Last;
103 MFOUTLINE First;
105
106 if (DegenerateOutline (Outline))
107 return (MicroFeatures);
108
109 First = NextExtremity (Outline);
110 Last = First;
111 do {
112 Current = NextExtremity (Last);
113 if (!PointAt(Current)->Hidden) {
114 NewFeature = ExtractMicroFeature (Last, Current);
115 if (NewFeature != nullptr)
116 MicroFeatures = push (MicroFeatures, NewFeature);
117 }
118 Last = Current;
119 }
120 while (Last != First);
121
122 return (MicroFeatures);
123} /* ConvertToMicroFeatures */
124
140 MFEDGEPT *P1, *P2;
141
142 P1 = PointAt(Start);
143 P2 = PointAt(End);
144
150 NewFeature[FIRSTBULGE] = 0.0f; // deprecated
151 NewFeature[SECONDBULGE] = 0.0f; // deprecated
152
153 return NewFeature;
154} /* ExtractMicroFeature */
#define double_VAR(name, val, comment)
Definition: params.h:312
float DistanceBetween(FPOINT A, FPOINT B)
Definition: fpoint.cpp:29
float NormalizedAngleFrom(FPOINT *Point1, FPOINT *Point2, float FullScale)
Definition: fpoint.cpp:44
MICROFEATURE NewMicroFeature()
Definition: mfdefs.cpp:33
float * MICROFEATURE
Definition: mfdefs.h:33
#define XPOSITION
Definition: mfdefs.h:36
#define MFLENGTH
Definition: mfdefs.h:38
#define YPOSITION
Definition: mfdefs.h:37
#define ORIENTATION
Definition: mfdefs.h:39
#define FIRSTBULGE
Definition: mfdefs.h:40
#define SECONDBULGE
Definition: mfdefs.h:41
LIST ConvertBlob(TBLOB *blob)
Definition: mfoutline.cpp:37
void FreeOutlines(LIST Outlines)
Definition: mfoutline.cpp:167
void FindDirectionChanges(MFOUTLINE Outline, float MinSlope, float MaxSlope)
Definition: mfoutline.cpp:115
MFOUTLINE NextExtremity(MFOUTLINE EdgePoint)
Definition: mfoutline.cpp:220
void CharNormalizeOutline(MFOUTLINE Outline, const DENORM &cn_denorm)
Definition: mfoutline.cpp:327
void MarkDirectionChanges(MFOUTLINE Outline)
Definition: mfoutline.cpp:183
#define AverageOf(A, B)
Definition: mfoutline.h:68
double classify_max_slope
Definition: mfx.cpp:37
MICROFEATURES BlobMicroFeatures(TBLOB *Blob, const DENORM &cn_denorm)
Definition: mfx.cpp:61
MICROFEATURES ConvertToMicroFeatures(MFOUTLINE Outline, MICROFEATURES MicroFeatures)
Definition: mfx.cpp:99
double classify_min_slope
Definition: mfx.cpp:35
MICROFEATURE ExtractMicroFeature(MFOUTLINE Start, MFOUTLINE End)
Definition: mfx.cpp:138
FEATURE NewFeature(const FEATURE_DESC_STRUCT *FeatureDesc)
Definition: ocrfeatures.cpp:78
LIST push(LIST list, void *element)
Definition: oldlist.cpp:213
#define iterate(l)
Definition: oldlist.h:101
#define first_node(l)
Definition: oldlist.h:92
#define NIL_LIST
Definition: oldlist.h:76
Definition: blobs.h:284
float y
Definition: fpoint.h:30
float x
Definition: fpoint.h:30
FPOINT Point
Definition: mfoutline.h:53