00001
00019 #ifndef MFOUTLINE_H
00020 #define MFOUTLINE_H
00021
00022
00023
00024
00025 #include "general.h"
00026 #include "oldlist.h"
00027 #include "fpoint.h"
00028 #include "fxdefs.h"
00029 #include "baseline.h"
00030
00031 #define NORMAL_X_HEIGHT (0.5)
00032 #define NORMAL_BASELINE (0.0)
00033
00038 typedef LIST MFOUTLINE;
00039
00044 typedef enum {
00045 north, south, east, west, northeast, northwest, southeast, southwest
00046 } DIRECTION;
00047
00048
00049
00050
00051
00052
00053
00054
00055
00060 typedef struct
00061 {
00062 FPOINT Point;
00063 FLOAT32 Slope;
00064 unsigned Padding:20;
00065 BOOL8 Hidden:TRUE;
00066 BOOL8 ExtremityMark:TRUE;
00067 DIRECTION Direction:4;
00068 DIRECTION PreviousDirection:4;
00069 } MFEDGEPT;
00070
00075 typedef enum {
00076 outer, hole
00077 } OUTLINETYPE;
00078
00079
00084 typedef struct
00085 {
00086 FLOAT64 Mx, My;
00087 FLOAT64 L;
00088 FLOAT64 x, y;
00089 FLOAT64 Ix, Iy;
00090 FLOAT64 Rx, Ry;
00091 } OUTLINE_STATS;
00092
00097 typedef enum {
00098 baseline, character
00099 } NORM_METHOD;
00100
00101
00102
00103
00104 extern int NormMethod;
00105
00106
00107
00108
00110 #define AverageOf(A,B) (((A) + (B)) / 2)
00111
00113 #define BaselineAt(L,X) (BASELINE_OFFSET)
00114
00116 #define ComputeScaleFactor(L) \
00117 (NORMAL_X_HEIGHT / ((is_baseline_normalized ())? \
00118 (BASELINE_SCALE): \
00119 ((L)->xheight)))
00120
00122 #define DegenerateOutline(O) (((O) == NIL) || ((O) == rest(O)))
00123 #define PointAt(O) ((MFEDGEPT *) first (O))
00124 #define NextPointAfter(E) (rest (E))
00125 #define MakeOutlineCircular(O) (set_rest (last (O), (O)))
00126
00128 #define PositionOf(P) ((P)->Point)
00129 #define XPositionOf(P) (PositionOf(P).x)
00130 #define YPositionOf(P) (PositionOf(P).y)
00131 #define DirectionOf(P) ((P)->Direction)
00132 #define PreviousDirectionOf(P) ((P)->PreviousDirection)
00133 #define ClearMark(P) ((P)->ExtremityMark = FALSE)
00134 #define MarkPoint(P) ((P)->ExtremityMark = TRUE)
00135 #define IsExtremity(P) ((P)->ExtremityMark)
00136 #define NotExtremity(P) (!IsExtremity(P))
00137 #define IsVisible(E) (! IsHidden(E))
00138 #define IsHidden(E) ((E)->Hidden)
00139
00140
00141
00142
00143 void ComputeBlobCenter(TBLOB *Blob, TPOINT *BlobCenter);
00144
00145 LIST ConvertBlob(TBLOB *Blob);
00146
00147 MFOUTLINE ConvertOutline(TESSLINE *Outline);
00148
00149 LIST ConvertOutlines(TESSLINE *Outline,
00150 LIST ConvertedOutlines,
00151 OUTLINETYPE OutlineType);
00152
00153 void ComputeOutlineStats(LIST Outlines, OUTLINE_STATS *OutlineStats);
00154
00155 void FilterEdgeNoise(MFOUTLINE Outline, FLOAT32 NoiseSegmentLength);
00156
00157 void FindDirectionChanges(MFOUTLINE Outline,
00158 FLOAT32 MinSlope,
00159 FLOAT32 MaxSlope);
00160
00161 void FreeMFOutline(void *agr);
00162
00163 void FreeOutlines(LIST Outlines);
00164
00165 void InitMFOutlineVars();
00166
00167 void MarkDirectionChanges(MFOUTLINE Outline);
00168
00169 MFEDGEPT *NewEdgePoint();
00170
00171 MFOUTLINE NextExtremity(MFOUTLINE EdgePoint);
00172
00173 void NormalizeOutline(MFOUTLINE Outline,
00174 LINE_STATS *LineStats,
00175 FLOAT32 XOrigin);
00176
00177 void NormalizeOutlines(LIST Outlines,
00178 LINE_STATS *LineStats,
00179 FLOAT32 *XScale,
00180 FLOAT32 *YScale);
00181
00182 void SettupBlobConversion(TBLOB *Blob);
00183
00184 void SmearExtremities(MFOUTLINE Outline, FLOAT32 XScale, FLOAT32 YScale);
00185
00186
00187
00188
00189 void ChangeDirection(MFOUTLINE Start, MFOUTLINE End, DIRECTION Direction);
00190
00191 void CharNormalizeOutline(MFOUTLINE Outline,
00192 FLOAT32 XCenter,
00193 FLOAT32 YCenter,
00194 FLOAT32 XScale,
00195 FLOAT32 YScale);
00196
00197 void ComputeDirection(MFEDGEPT *Start,
00198 MFEDGEPT *Finish,
00199 FLOAT32 MinSlope,
00200 FLOAT32 MaxSlope);
00201
00202 void FinishOutlineStats(register OUTLINE_STATS *OutlineStats);
00203
00204 void InitOutlineStats(OUTLINE_STATS *OutlineStats);
00205
00206 MFOUTLINE NextDirectionChange(MFOUTLINE EdgePoint);
00207
00208 void UpdateOutlineStats(register OUTLINE_STATS *OutlineStats,
00209 register FLOAT32 x1,
00210 register FLOAT32 x2,
00211 register FLOAT32 y1,
00212 register FLOAT32 y2);
00213
00214
00215
00216
00217
00218
00219
00220
00221
00222
00223
00224
00225
00226
00227
00228
00229
00230
00231
00232
00233
00234
00235
00236
00237
00238
00239
00240
00241
00242
00243
00244
00245
00246
00247
00248
00249
00250
00251
00252
00253
00254
00255
00256
00257
00258
00259
00260
00261
00262
00263
00264
00265
00266
00267
00268
00269
00270
00271
00272
00273
00274
00275
00276
00277
00278
00279
00280
00281
00282
00283
00284
00285
00286
00287
00288
00289
00290 extern int NormMethod;
00291 #endif