tesseract  4.1.0
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

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 */
void CharNormalizeOutline(MFOUTLINE Outline, const DENORM &cn_denorm)
Definition: mfoutline.cpp:326
void FreeOutlines(LIST Outlines)
Definition: mfoutline.cpp:167
double classify_max_slope
Definition: mfx.cpp:37
void FindDirectionChanges(MFOUTLINE Outline, float MinSlope, float MaxSlope)
Definition: mfoutline.cpp:115
double classify_min_slope
Definition: mfx.cpp:35
MICROFEATURES ConvertToMicroFeatures(MFOUTLINE Outline, MICROFEATURES MicroFeatures)
Definition: mfx.cpp:99
#define NIL_LIST
Definition: oldlist.h:76
void MarkDirectionChanges(MFOUTLINE Outline)
Definition: mfoutline.cpp:183
#define first_node(l)
Definition: oldlist.h:92
LIST ConvertBlob(TBLOB *blob)
Definition: mfoutline.cpp:37
#define iterate(l)
Definition: oldlist.h:101
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 */
FEATURE NewFeature(const FEATURE_DESC_STRUCT *FeatureDesc)
Definition: ocrfeatures.cpp:78
#define DegenerateOutline(O)
Definition: mfoutline.h:68
MFOUTLINE NextExtremity(MFOUTLINE EdgePoint)
Definition: mfoutline.cpp:220
LIST push(LIST list, void *element)
Definition: oldlist.cpp:219
MICROFEATURE ExtractMicroFeature(MFOUTLINE Start, MFOUTLINE End)
Definition: mfx.cpp:138
float * MICROFEATURE
Definition: mfdefs.h:33
#define PointAt(O)
Definition: mfoutline.h:69
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 
145  NewFeature = NewMicroFeature ();
146  NewFeature[XPOSITION] = AverageOf(P1->Point.x, P2->Point.x);
147  NewFeature[YPOSITION] = AverageOf(P1->Point.y, P2->Point.y);
148  NewFeature[MFLENGTH] = DistanceBetween(P1->Point, P2->Point);
149  NewFeature[ORIENTATION] = NormalizedAngleFrom(&P1->Point, &P2->Point, 1.0);
150  NewFeature[FIRSTBULGE] = 0.0f; // deprecated
151  NewFeature[SECONDBULGE] = 0.0f; // deprecated
152 
153  return NewFeature;
154 } /* ExtractMicroFeature */
float NormalizedAngleFrom(FPOINT *Point1, FPOINT *Point2, float FullScale)
Definition: fpoint.cpp:44
#define SECONDBULGE
Definition: mfdefs.h:41
#define XPOSITION
Definition: mfdefs.h:36
FEATURE NewFeature(const FEATURE_DESC_STRUCT *FeatureDesc)
Definition: ocrfeatures.cpp:78
float y
Definition: fpoint.h:30
float DistanceBetween(FPOINT A, FPOINT B)
Definition: fpoint.cpp:29
#define ORIENTATION
Definition: mfdefs.h:39
float * MICROFEATURE
Definition: mfdefs.h:33
#define YPOSITION
Definition: mfdefs.h:37
#define PointAt(O)
Definition: mfoutline.h:69
MICROFEATURE NewMicroFeature()
Definition: mfdefs.cpp:33
#define MFLENGTH
Definition: mfdefs.h:38
FPOINT Point
Definition: mfoutline.h:46
float x
Definition: fpoint.h:30
#define FIRSTBULGE
Definition: mfdefs.h:40
#define AverageOf(A, B)
Definition: mfoutline.h:62

Variable Documentation

double classify_max_slope = 2.414213562

"Slope above which lines are called vertical"

Definition at line 37 of file mfx.cpp.

double classify_min_slope = 0.414213562

"Slope below which lines are called horizontal"

Definition at line 35 of file mfx.cpp.