All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
mfx.cpp File Reference
#include "mfdefs.h"
#include "mfoutline.h"
#include "clusttool.h"
#include "const.h"
#include "intfx.h"
#include "normalis.h"
#include "params.h"
#include <math.h>

Go to the source code of this file.

Macros

#define NormalizeAngle(A)   ( (((A)<0)?((A)+2*PI):(A)) / (2*PI) )
 

Functions

FLOAT32 ComputeOrientation (MFEDGEPT *Start, MFEDGEPT *End)
 
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
 

Macro Definition Documentation

#define NormalizeAngle (   A)    ( (((A)<0)?((A)+2*PI):(A)) / (2*PI) )

Definition at line 45 of file mfx.cpp.

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.
Note
Exceptions: none
History: 7/21/89, DSJ, Created.

Definition at line 72 of file mfx.cpp.

72  {
73  MICROFEATURES MicroFeatures = NIL_LIST;
74  LIST Outlines;
75  LIST RemainingOutlines;
76  MFOUTLINE Outline;
77 
78  if (Blob != NULL) {
79  Outlines = ConvertBlob(Blob);
80 
81  RemainingOutlines = Outlines;
82  iterate(RemainingOutlines) {
83  Outline = (MFOUTLINE) first_node (RemainingOutlines);
84  CharNormalizeOutline(Outline, cn_denorm);
85  }
86 
87  RemainingOutlines = Outlines;
88  iterate(RemainingOutlines) {
89  Outline = (MFOUTLINE) first_node(RemainingOutlines);
91  MarkDirectionChanges(Outline);
92  MicroFeatures = ConvertToMicroFeatures(Outline, MicroFeatures);
93  }
94  FreeOutlines(Outlines);
95  }
96  return MicroFeatures;
97 } /* BlobMicroFeatures */
void CharNormalizeOutline(MFOUTLINE Outline, const DENORM &cn_denorm)
Definition: mfoutline.cpp:359
#define NIL_LIST
Definition: oldlist.h:126
double classify_min_slope
Definition: mfx.cpp:37
void FindDirectionChanges(MFOUTLINE Outline, FLOAT32 MinSlope, FLOAT32 MaxSlope)
Definition: mfoutline.cpp:120
LIST ConvertBlob(TBLOB *blob)
Definition: mfoutline.cpp:39
void FreeOutlines(LIST Outlines)
Definition: mfoutline.cpp:178
#define first_node(l)
Definition: oldlist.h:139
#define iterate(l)
Definition: oldlist.h:159
void MarkDirectionChanges(MFOUTLINE Outline)
Definition: mfoutline.cpp:198
#define NULL
Definition: host.h:144
MICROFEATURES ConvertToMicroFeatures(MFOUTLINE Outline, MICROFEATURES MicroFeatures)
Definition: mfx.cpp:141
double classify_max_slope
Definition: mfx.cpp:39
LIST MFOUTLINE
Definition: mfoutline.h:33
FLOAT32 ComputeOrientation ( MFEDGEPT Start,
MFEDGEPT End 
)

This routine computes the orientation parameter of the specified micro-feature. The orientation is the angle of the vector from Start to End. It is normalized to a number between 0 and 1 where 0 corresponds to 0 degrees and 1 corresponds to 360 degrees. The actual range is [0,1), i.e. 1 is excluded from the range (since it is actual the same orientation as 0). This routine assumes that Start and End are not the same point.

Parameters
Startstarting edge point of micro-feature
Endending edge point of micro-feature
Note
Globals: none
Returns
Orientation parameter for the specified micro-feature.
Note
Exceptions: none
History: 7/27/89, DSJ, Created.

Definition at line 120 of file mfx.cpp.

120  {
122 
123  Orientation = NormalizeAngle (AngleFrom (Start->Point, End->Point));
124 
125  /* ensure that round-off errors do not put circular param out of range */
126  if ((Orientation < 0) || (Orientation >= 1))
127  Orientation = 0;
128  return (Orientation);
129 } /* ComputeOrientation */
#define NormalizeAngle(A)
Definition: mfx.cpp:45
float FLOAT32
Definition: host.h:111
#define AngleFrom(A, B)
Definition: fpoint.h:42
FPOINT Point
Definition: mfoutline.h:40
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
Exceptions: none
History: 7/26/89, DSJ, Created.

Definition at line 141 of file mfx.cpp.

142  {
143  MFOUTLINE Current;
144  MFOUTLINE Last;
145  MFOUTLINE First;
147 
148  if (DegenerateOutline (Outline))
149  return (MicroFeatures);
150 
151  First = NextExtremity (Outline);
152  Last = First;
153  do {
154  Current = NextExtremity (Last);
155  if (!PointAt(Current)->Hidden) {
156  NewFeature = ExtractMicroFeature (Last, Current);
157  if (NewFeature != NULL)
158  MicroFeatures = push (MicroFeatures, NewFeature);
159  }
160  Last = Current;
161  }
162  while (Last != First);
163 
164  return (MicroFeatures);
165 } /* ConvertToMicroFeatures */
FEATURE NewFeature(const FEATURE_DESC_STRUCT *FeatureDesc)
Definition: ocrfeatures.cpp:96
FLOAT32 * MICROFEATURE
Definition: mfdefs.h:33
MFOUTLINE NextExtremity(MFOUTLINE EdgePoint)
Definition: mfoutline.cpp:238
#define PointAt(O)
Definition: mfoutline.h:67
#define DegenerateOutline(O)
Definition: mfoutline.h:66
#define NULL
Definition: host.h:144
MICROFEATURE ExtractMicroFeature(MFOUTLINE Start, MFOUTLINE End)
Definition: mfx.cpp:185
LIST push(LIST list, void *element)
Definition: oldlist.cpp:323
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, NULL 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 NULL if the feature was rejected.
Note
Globals: none
Exceptions: none
History:
  • 7/26/89, DSJ, Created.
  • 11/17/89, DSJ, Added handling for Start and End same point.

Definition at line 185 of file mfx.cpp.

185  {
187  MFEDGEPT *P1, *P2;
188 
189  P1 = PointAt(Start);
190  P2 = PointAt(End);
191 
192  NewFeature = NewMicroFeature ();
193  NewFeature[XPOSITION] = AverageOf(P1->Point.x, P2->Point.x);
194  NewFeature[YPOSITION] = AverageOf(P1->Point.y, P2->Point.y);
195  NewFeature[MFLENGTH] = DistanceBetween(P1->Point, P2->Point);
196  NewFeature[ORIENTATION] = NormalizedAngleFrom(&P1->Point, &P2->Point, 1.0);
197  NewFeature[FIRSTBULGE] = 0.0f; // deprecated
198  NewFeature[SECONDBULGE] = 0.0f; // deprecated
199 
200  return NewFeature;
201 } /* ExtractMicroFeature */
#define FIRSTBULGE
Definition: mfdefs.h:40
#define AverageOf(A, B)
Definition: mfoutline.h:60
#define XPOSITION
Definition: mfdefs.h:36
FEATURE NewFeature(const FEATURE_DESC_STRUCT *FeatureDesc)
Definition: ocrfeatures.cpp:96
#define YPOSITION
Definition: mfdefs.h:37
FLOAT32 NormalizedAngleFrom(FPOINT *Point1, FPOINT *Point2, FLOAT32 FullScale)
Definition: fpoint.cpp:48
FLOAT32 * MICROFEATURE
Definition: mfdefs.h:33
#define SECONDBULGE
Definition: mfdefs.h:41
MICROFEATURE NewMicroFeature()
Definition: mfdefs.cpp:35
#define PointAt(O)
Definition: mfoutline.h:67
FLOAT32 DistanceBetween(FPOINT A, FPOINT B)
Definition: fpoint.cpp:30
FLOAT32 y
Definition: fpoint.h:31
#define ORIENTATION
Definition: mfdefs.h:39
FPOINT Point
Definition: mfoutline.h:40
FLOAT32 x
Definition: fpoint.h:31
#define MFLENGTH
Definition: mfdefs.h:38

Variable Documentation

double classify_max_slope = 2.414213562

"Slope above which lines are called vertical"

Definition at line 39 of file mfx.cpp.

double classify_min_slope = 0.414213562

"Slope below which lines are called horizontal"

Definition at line 37 of file mfx.cpp.