Tesseract
3.02
|
00001 /****************************************************************************** 00002 ** Filename: mfoutline.h 00003 ** Purpose: Interface spec for fx outline structures 00004 ** Author: Dan Johnson 00005 ** History: Thu May 17 08:55:32 1990, DSJ, Created. 00006 ** 00007 ** (c) Copyright Hewlett-Packard Company, 1988. 00008 ** Licensed under the Apache License, Version 2.0 (the "License"); 00009 ** you may not use this file except in compliance with the License. 00010 ** You may obtain a copy of the License at 00011 ** http://www.apache.org/licenses/LICENSE-2.0 00012 ** Unless required by applicable law or agreed to in writing, software 00013 ** distributed under the License is distributed on an "AS IS" BASIS, 00014 ** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 00015 ** See the License for the specific language governing permissions and 00016 ** limitations under the License. 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; /* first moment of all outlines */ 00055 FLOAT64 L; /* total length of all outlines */ 00056 FLOAT64 x, y; /* center of mass of all outlines */ 00057 FLOAT64 Ix, Iy; /* second moments about center of mass axes */ 00058 FLOAT64 Rx, Ry; /* radius of gyration about center of mass axes */ 00059 } OUTLINE_STATS; 00060 00061 typedef enum { 00062 baseline, character 00063 } NORM_METHOD; 00064 00068 #define AverageOf(A,B) (((A) + (B)) / 2) 00069 00070 /* macro for computing the scale factor to use to normalize characters */ 00071 #define MF_SCALE_FACTOR (NORMAL_X_HEIGHT / BASELINE_SCALE) 00072 00073 /* macros for manipulating micro-feature outlines */ 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 /* macros for manipulating micro-feature outline edge points */ 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); //MFOUTLINE Outline); 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 Private Function Prototypes 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