|
tesseract 3.04.01
|
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 "blobs.h" 00025 #include "host.h" 00026 #include "oldlist.h" 00027 #include "fpoint.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 enum { 00054 baseline, character 00055 } NORM_METHOD; 00056 00060 #define AverageOf(A,B) (((A) + (B)) / 2) 00061 00062 /* macro for computing the scale factor to use to normalize characters */ 00063 #define MF_SCALE_FACTOR (NORMAL_X_HEIGHT / kBlnXHeight) 00064 00065 /* macros for manipulating micro-feature outlines */ 00066 #define DegenerateOutline(O) (((O) == NIL_LIST) || ((O) == list_rest(O))) 00067 #define PointAt(O) ((MFEDGEPT *) first_node (O)) 00068 #define NextPointAfter(E) (list_rest (E)) 00069 #define MakeOutlineCircular(O) (set_rest (last (O), (O))) 00070 00071 /* macros for manipulating micro-feature outline edge points */ 00072 #define ClearMark(P) ((P)->ExtremityMark = FALSE) 00073 #define MarkPoint(P) ((P)->ExtremityMark = TRUE) 00074 00078 void ComputeBlobCenter(TBLOB *Blob, TPOINT *BlobCenter); 00079 00080 LIST ConvertBlob(TBLOB *Blob); 00081 00082 MFOUTLINE ConvertOutline(TESSLINE *Outline); 00083 00084 LIST ConvertOutlines(TESSLINE *Outline, 00085 LIST ConvertedOutlines, 00086 OUTLINETYPE OutlineType); 00087 00088 void FilterEdgeNoise(MFOUTLINE Outline, FLOAT32 NoiseSegmentLength); 00089 00090 void FindDirectionChanges(MFOUTLINE Outline, 00091 FLOAT32 MinSlope, 00092 FLOAT32 MaxSlope); 00093 00094 void FreeMFOutline(void *agr); //MFOUTLINE Outline); 00095 00096 void FreeOutlines(LIST Outlines); 00097 00098 void MarkDirectionChanges(MFOUTLINE Outline); 00099 00100 MFEDGEPT *NewEdgePoint(); 00101 00102 MFOUTLINE NextExtremity(MFOUTLINE EdgePoint); 00103 00104 void NormalizeOutline(MFOUTLINE Outline, 00105 FLOAT32 XOrigin); 00106 00107 /*---------------------------------------------------------------------------- 00108 Private Function Prototypes 00109 -----------------------------------------------------------------------------*/ 00110 void ChangeDirection(MFOUTLINE Start, MFOUTLINE End, DIRECTION Direction); 00111 00112 // Normalizes the Outline in-place using cn_denorm's local transformation, 00113 // then converts from the integer feature range [0,255] to the clusterer 00114 // feature range of [-0.5, 0.5]. 00115 void CharNormalizeOutline(MFOUTLINE Outline, const DENORM& cn_denorm); 00116 00117 void ComputeDirection(MFEDGEPT *Start, 00118 MFEDGEPT *Finish, 00119 FLOAT32 MinSlope, 00120 FLOAT32 MaxSlope); 00121 00122 MFOUTLINE NextDirectionChange(MFOUTLINE EdgePoint); 00123 00124 #endif