classify/mfoutline.h

Go to the documentation of this file.
00001 
00019 #ifndef   MFOUTLINE_H
00020 #define   MFOUTLINE_H
00021 
00022 /* =================
00023           Include Files and Type Defines
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 typedef enum
00050 {
00051 False, True
00052 }
00053 BOOLEAN;
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             Variables
00103 ------------------------------------------------------------------------------*/
00104 extern int NormMethod;
00105 
00106 /* =================
00107           Macros
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           Public Function Prototypes
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);  //MFOUTLINE                             Outline);
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           Private Function Prototypes
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 #if defined(__STDC__) || defined(__cplusplus)
00216 # define _ARGS(s) s
00217 #else
00218 # define _ARGS(s) ()
00219 #endif*/
00220 
00221 /* mfoutline.c
00222 void ComputeBlobCenter
00223   _ARGS((BLOB *Blob,
00224   TPOINT *BlobCenter));
00225 
00226 LIST ConvertBlob
00227   _ARGS((BLOB *Blob));
00228 
00229 MFOUTLINE ConvertOutline
00230   _ARGS((TESSLINE *Outline));
00231 
00232 LIST ConvertOutlines
00233   _ARGS((TESSLINE *Outline,
00234   LIST ConvertedOutlines,
00235   OUTLINETYPE OutlineType));
00236 
00237 void ComputeOutlineStats
00238   _ARGS((LIST Outlines,
00239   OUTLINE_STATS *OutlineStats));
00240 
00241 void FilterEdgeNoise
00242   _ARGS((MFOUTLINE Outline,
00243   FLOAT32 NoiseSegmentLength));
00244 
00245 void FindDirectionChanges
00246   _ARGS((MFOUTLINE Outline,
00247   FLOAT32 MinSlope,
00248   FLOAT32 MaxSlope));
00249 
00250 void FreeMFOutline
00251   _ARGS((MFOUTLINE Outline));
00252 
00253 void FreeOutlines
00254   _ARGS((LIST Outlines));
00255 
00256 void InitMFOutlineVars
00257   _ARGS((void));
00258 
00259 void MarkDirectionChanges
00260   _ARGS((MFOUTLINE Outline));
00261 
00262 MFEDGEPT *NewEdgePoint
00263   _ARGS((void));
00264 
00265 MFOUTLINE NextExtremity
00266   _ARGS((MFOUTLINE EdgePoint));
00267 
00268 void NormalizeOutline
00269   _ARGS((MFOUTLINE Outline,
00270   LINE_STATS *LineStats,
00271   FLOAT32 XOrigin));
00272 
00273 void NormalizeOutlines
00274   _ARGS((LIST Outlines,
00275   LINE_STATS *LineStats));
00276 
00277 void SettupBlobConversion
00278   _ARGS((BLOB *Blob));
00279 
00280 void SmearExtremities
00281   _ARGS((MFOUTLINE Outline,
00282   FLOAT32 XScale,
00283   FLOAT32 YScale));
00284 
00285 #undef _ARGS
00286 */
00287 /* =================
00288         Global Data Definitions and Declarations
00289  ==================== */
00290 extern int NormMethod;           /* normalized method currently selected */
00291 #endif

Generated on Wed Feb 28 19:49:10 2007 for Tesseract by  doxygen 1.5.1