tesseract 4.1.1
Loading...
Searching...
No Matches
mfx.cpp File Reference
#include "mfx.h"
#include "mfdefs.h"
#include "mfoutline.h"
#include "clusttool.h"
#include "intfx.h"
#include "normalis.h"
#include "params.h"

Go to the source code of this file.

Functions

MICROFEATURES ConvertToMicroFeatures (MFOUTLINE Outline, MICROFEATURES MicroFeatures)
 
MICROFEATURE ExtractMicroFeature (MFOUTLINE Start, MFOUTLINE End)
 
MICROFEATURES BlobMicroFeatures (TBLOB *Blob, const DENORM &cn_denorm)
 

Variables

double classify_min_slope = 0.414213562
 
double classify_max_slope = 2.414213562
 

Function Documentation

◆ BlobMicroFeatures()

MICROFEATURES BlobMicroFeatures ( TBLOB Blob,
const DENORM cn_denorm 
)

This routine extracts micro-features from the specified blob and returns a list of the micro-features. All micro-features are normalized according to the specified line statistics.

Parameters
Blobblob to extract micro-features from
cn_denormcontrol parameter to feature extractor
Returns
List of micro-features extracted from the blob.

Definition at line 61 of file mfx.cpp.

61 {
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 */
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
void CharNormalizeOutline(MFOUTLINE Outline, const DENORM &cn_denorm)
Definition: mfoutline.cpp:327
void MarkDirectionChanges(MFOUTLINE Outline)
Definition: mfoutline.cpp:183
double classify_max_slope
Definition: mfx.cpp:37
MICROFEATURES ConvertToMicroFeatures(MFOUTLINE Outline, MICROFEATURES MicroFeatures)
Definition: mfx.cpp:99
double classify_min_slope
Definition: mfx.cpp:35
#define iterate(l)
Definition: oldlist.h:101
#define first_node(l)
Definition: oldlist.h:92
#define NIL_LIST
Definition: oldlist.h:76

◆ ConvertToMicroFeatures()

MICROFEATURES ConvertToMicroFeatures ( MFOUTLINE  Outline,
MICROFEATURES  MicroFeatures 
)

Convert Outline to MicroFeatures

Parameters
Outlineoutline to extract micro-features from
MicroFeatureslist of micro-features to add to
Returns
List of micro-features with new features added to front.
Note
Globals: none

Definition at line 99 of file mfx.cpp.

100 {
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 */
float * MICROFEATURE
Definition: mfdefs.h:33
MFOUTLINE NextExtremity(MFOUTLINE EdgePoint)
Definition: mfoutline.cpp:220
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

◆ ExtractMicroFeature()

MICROFEATURE ExtractMicroFeature ( MFOUTLINE  Start,
MFOUTLINE  End 
)

This routine computes the feature parameters which describe the micro-feature that starts and Start and ends at End. A new micro-feature is allocated, filled with the feature parameters, and returned. The routine assumes that Start and End are not the same point. If they are the same point, nullptr is returned, a warning message is printed, and the current outline is dumped to stdout.

Parameters
Startstarting point of micro-feature
Endending point of micro-feature
Returns
New micro-feature or nullptr if the feature was rejected.
Note
Globals: none

Definition at line 138 of file mfx.cpp.

138 {
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 */
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
#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
#define AverageOf(A, B)
Definition: mfoutline.h:68
float y
Definition: fpoint.h:30
float x
Definition: fpoint.h:30
FPOINT Point
Definition: mfoutline.h:53

Variable Documentation

◆ classify_max_slope

double classify_max_slope = 2.414213562

"Slope above which lines are called vertical"

Definition at line 37 of file mfx.cpp.

◆ classify_min_slope

double classify_min_slope = 0.414213562

"Slope below which lines are called horizontal"

Definition at line 35 of file mfx.cpp.