tesseract  5.0.0-alpha-619-ge9db
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 60 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;

◆ 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 98 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);

◆ 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 137 of file mfx.cpp.

138  {
140  MFEDGEPT *P1, *P2;
141 
142  P1 = PointAt(Start);
143  P2 = PointAt(End);
144 
146  NewFeature[XPOSITION] = AverageOf(P1->Point.x, P2->Point.x);
147  NewFeature[YPOSITION] = AverageOf(P1->Point.y, P2->Point.y);
150  NewFeature[FIRSTBULGE] = 0.0f; // deprecated
151  NewFeature[SECONDBULGE] = 0.0f; // deprecated
152 
153  return NewFeature;

Variable Documentation

◆ classify_max_slope

double classify_max_slope = 2.414213562

"Slope above which lines are called vertical"

Definition at line 36 of file mfx.cpp.

◆ classify_min_slope

double classify_min_slope = 0.414213562

"Slope below which lines are called horizontal"

Definition at line 34 of file mfx.cpp.

MFEDGEPT::Point
FPOINT Point
Definition: mfoutline.h:52
first_node
#define first_node(l)
Definition: oldlist.h:84
FPOINT::y
float y
Definition: fpoint.h:44
list_rec
Definition: oldlist.h:73
NormalizedAngleFrom
float NormalizedAngleFrom(FPOINT *Point1, FPOINT *Point2, float FullScale)
Definition: fpoint.cpp:43
MarkDirectionChanges
void MarkDirectionChanges(MFOUTLINE Outline)
Definition: mfoutline.cpp:182
CharNormalizeOutline
void CharNormalizeOutline(MFOUTLINE Outline, const DENORM &cn_denorm)
Definition: mfoutline.cpp:326
FIRSTBULGE
#define FIRSTBULGE
Definition: mfdefs.h:39
FPOINT::x
float x
Definition: fpoint.h:44
NIL_LIST
#define NIL_LIST
Definition: oldlist.h:68
XPOSITION
#define XPOSITION
Definition: mfdefs.h:35
classify_max_slope
double classify_max_slope
Definition: mfx.cpp:36
FindDirectionChanges
void FindDirectionChanges(MFOUTLINE Outline, float MinSlope, float MaxSlope)
Definition: mfoutline.cpp:114
ConvertToMicroFeatures
MICROFEATURES ConvertToMicroFeatures(MFOUTLINE Outline, MICROFEATURES MicroFeatures)
Definition: mfx.cpp:98
DistanceBetween
float DistanceBetween(FPOINT A, FPOINT B)
Definition: fpoint.cpp:28
ConvertBlob
LIST ConvertBlob(TBLOB *blob)
Definition: mfoutline.cpp:36
classify_min_slope
double classify_min_slope
Definition: mfx.cpp:34
ORIENTATION
#define ORIENTATION
Definition: mfdefs.h:38
push
LIST push(LIST list, void *element)
Definition: oldlist.cpp:172
NewFeature
FEATURE NewFeature(const FEATURE_DESC_STRUCT *FeatureDesc)
Definition: ocrfeatures.cpp:77
FreeOutlines
void FreeOutlines(LIST Outlines)
Definition: mfoutline.cpp:166
YPOSITION
#define YPOSITION
Definition: mfdefs.h:36
MFEDGEPT
Definition: mfoutline.h:41
iterate
#define iterate(l)
Definition: oldlist.h:92
ExtractMicroFeature
MICROFEATURE ExtractMicroFeature(MFOUTLINE Start, MFOUTLINE End)
Definition: mfx.cpp:137
NewMicroFeature
MICROFEATURE NewMicroFeature()
Definition: mfdefs.cpp:32
MFLENGTH
#define MFLENGTH
Definition: mfdefs.h:37
NextExtremity
MFOUTLINE NextExtremity(MFOUTLINE EdgePoint)
Definition: mfoutline.cpp:219
AverageOf
#define AverageOf(A, B)
Definition: mfoutline.h:67
SECONDBULGE
#define SECONDBULGE
Definition: mfdefs.h:40
MICROFEATURE
float * MICROFEATURE
Definition: mfdefs.h:32