00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018 #ifndef MFOUTLINE_H
00019 #define MFOUTLINE_H
00020
00024 #include "host.h"
00025 #include "oldlist.h"
00026 #include "fpoint.h"
00027 #include "baseline.h"
00028 #include "params.h"
00029
00030 #define NORMAL_X_HEIGHT (0.5)
00031 #define NORMAL_BASELINE (0.0)
00032
00033 typedef LIST MFOUTLINE;
00034
00035 typedef enum {
00036 north, south, east, west, northeast, northwest, southeast, southwest
00037 } DIRECTION;
00038
00039 typedef struct {
00040 FPOINT Point;
00041 FLOAT32 Slope;
00042 unsigned Padding:20;
00043 BOOL8 Hidden:TRUE;
00044 BOOL8 ExtremityMark:TRUE;
00045 DIRECTION Direction:4;
00046 DIRECTION PreviousDirection:4;
00047 } MFEDGEPT;
00048
00049 typedef enum {
00050 outer, hole
00051 } OUTLINETYPE;
00052
00053 typedef struct {
00054 FLOAT64 Mx, My;
00055 FLOAT64 L;
00056 FLOAT64 x, y;
00057 FLOAT64 Ix, Iy;
00058 FLOAT64 Rx, Ry;
00059 } OUTLINE_STATS;
00060
00061 typedef enum {
00062 baseline, character
00063 } NORM_METHOD;
00064
00068 #define AverageOf(A,B) (((A) + (B)) / 2)
00069
00070
00071 #define MF_SCALE_FACTOR (NORMAL_X_HEIGHT / BASELINE_SCALE)
00072
00073
00074 #define DegenerateOutline(O) (((O) == NIL_LIST) || ((O) == list_rest(O)))
00075 #define PointAt(O) ((MFEDGEPT *) first_node (O))
00076 #define NextPointAfter(E) (list_rest (E))
00077 #define MakeOutlineCircular(O) (set_rest (last (O), (O)))
00078
00079
00080 #define ClearMark(P) ((P)->ExtremityMark = FALSE)
00081 #define MarkPoint(P) ((P)->ExtremityMark = TRUE)
00082
00086 void ComputeBlobCenter(TBLOB *Blob, TPOINT *BlobCenter);
00087
00088 LIST ConvertBlob(TBLOB *Blob);
00089
00090 MFOUTLINE ConvertOutline(TESSLINE *Outline);
00091
00092 LIST ConvertOutlines(TESSLINE *Outline,
00093 LIST ConvertedOutlines,
00094 OUTLINETYPE OutlineType);
00095
00096 void ComputeOutlineStats(LIST Outlines, OUTLINE_STATS *OutlineStats);
00097
00098 void FilterEdgeNoise(MFOUTLINE Outline, FLOAT32 NoiseSegmentLength);
00099
00100 void FindDirectionChanges(MFOUTLINE Outline,
00101 FLOAT32 MinSlope,
00102 FLOAT32 MaxSlope);
00103
00104 void FreeMFOutline(void *agr);
00105
00106 void FreeOutlines(LIST Outlines);
00107
00108 void MarkDirectionChanges(MFOUTLINE Outline);
00109
00110 MFEDGEPT *NewEdgePoint();
00111
00112 MFOUTLINE NextExtremity(MFOUTLINE EdgePoint);
00113
00114 void NormalizeOutline(MFOUTLINE Outline,
00115 FLOAT32 XOrigin);
00116
00117
00118
00119
00120 void ChangeDirection(MFOUTLINE Start, MFOUTLINE End, DIRECTION Direction);
00121
00122 void CharNormalizeOutline(MFOUTLINE Outline,
00123 FLOAT32 XCenter,
00124 FLOAT32 YCenter,
00125 FLOAT32 XScale,
00126 FLOAT32 YScale);
00127
00128 void ComputeDirection(MFEDGEPT *Start,
00129 MFEDGEPT *Finish,
00130 FLOAT32 MinSlope,
00131 FLOAT32 MaxSlope);
00132
00133 void FinishOutlineStats(register OUTLINE_STATS *OutlineStats);
00134
00135 void InitOutlineStats(OUTLINE_STATS *OutlineStats);
00136
00137 MFOUTLINE NextDirectionChange(MFOUTLINE EdgePoint);
00138
00139 void UpdateOutlineStats(register OUTLINE_STATS *OutlineStats,
00140 register FLOAT32 x1,
00141 register FLOAT32 x2,
00142 register FLOAT32 y1,
00143 register FLOAT32 y2);
00144
00145 #endif