#include "ocrfeatures.h"
#include "tessclas.h"
#include "fxdefs.h"
Go to the source code of this file.
#define LENGTH_COMPRESSION (10.0) |
** (c) Copyright Hewlett-Packard Company, 1988. ** Licensed under the Apache License, Version 2.0 (the "License"); ** you may not use this file except in compliance with the License. ** You may obtain a copy of the License at ** http://www.apache.org/licenses/LICENSE-2.0 ** Unless required by applicable law or agreed to in writing, software ** distributed under the License is distributed on an "AS IS" BASIS, ** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. ** See the License for the specific language governing permissions and ** limitations under the License.
Definition at line 29 of file normfeat.h.
Referenced by ActualOutlineLength(), ExtractCharNormFeatures(), and GetIntCharNormFeatures().
enum NORM_PARAM_NAME |
Information on something normalized ??
Definition at line 35 of file normfeat.h.
00036 { 00037 CharNormY, 00038 CharNormLength, 00039 CharNormRx, 00040 CharNormRy 00041 } NORM_PARAM_NAME;
Computes the length that the outline would have been if it were baseline normalized instead of character normalized.
Feature | Normalization feature |
Definition at line 49 of file normfeat.cpp.
References CharNormLength, LENGTH_COMPRESSION, and ParamOf.
00049 { 00050 return (ParamOf (Feature, CharNormLength) * LENGTH_COMPRESSION); 00051 00052 } /* ActualOutlineLength */
FEATURE_SET ExtractCharNormFeatures | ( | TBLOB * | Blob, | |
LINE_STATS * | LineStats | |||
) |
Compute a feature whose parameters describe how a character will be affected by the character normalization algorithm.
Blob | Blob to extract char norm feature from | |
LineStats | Statistics on text row blob is in |
Definition at line 72 of file normfeat.cpp.
References AddFeature(), BaselineAt, CharNormDesc, CharNormLength, CharNormRx, CharNormRy, CharNormY, ComputeScaleFactor, ConvertBlob(), ExtractIntFeat(), FreeOutlines(), FXInfo, INT_FX_RESULT_STRUCT::Length, LENGTH_COMPRESSION, NewFeature(), NewFeatureSet(), ParamOf, INT_FX_RESULT_STRUCT::Rx, INT_FX_RESULT_STRUCT::Ry, INT_FX_RESULT_STRUCT::Xmean, and INT_FX_RESULT_STRUCT::Ymean.
00072 { 00073 FEATURE_SET FeatureSet; 00074 FEATURE Feature; 00075 FLOAT32 Scale; 00076 FLOAT32 Baseline; 00077 LIST Outlines; 00078 INT_FEATURE_ARRAY blfeatures; 00079 INT_FEATURE_ARRAY cnfeatures; 00080 INT_FX_RESULT_STRUCT FXInfo; 00081 00082 /* allocate the feature and feature set - note that there is always one 00083 and only one char normalization feature for any blob */ 00084 FeatureSet = NewFeatureSet (1); 00085 Feature = NewFeature (&CharNormDesc); 00086 AddFeature(FeatureSet, Feature); 00087 00088 /* compute the normalization statistics for this blob */ 00089 Outlines = ConvertBlob (Blob); 00090 /*---------Debug--------------------------------------------------* 00091 OFile = fopen ("f:/ims/debug/nfOutline.logCPP", "r"); 00092 if (OFile == NULL) 00093 { 00094 OFile = Efopen ("f:/ims/debug/nfOutline.logCPP", "w"); 00095 WriteOutlines(OFile, Outlines); 00096 } 00097 else 00098 { 00099 fclose (OFile); 00100 OFile = Efopen ("f:/ims/debug/nfOutline.logCPP", "a"); 00101 } 00102 WriteOutlines(OFile, Outlines); 00103 fclose (OFile); 00104 *--------------------------------------------------------------------*/ 00105 00106 ExtractIntFeat(Blob, blfeatures, cnfeatures, &FXInfo); 00107 Baseline = BaselineAt (LineStats, FXInfo.Xmean); 00108 Scale = ComputeScaleFactor (LineStats); 00109 ParamOf (Feature, CharNormY) = (FXInfo.Ymean - Baseline) * Scale; 00110 ParamOf (Feature, CharNormLength) = 00111 FXInfo.Length * Scale / LENGTH_COMPRESSION; 00112 ParamOf (Feature, CharNormRx) = FXInfo.Rx * Scale; 00113 ParamOf (Feature, CharNormRy) = FXInfo.Ry * Scale; 00114 00115 /*---------Debug--------------------------------------------------* 00116 File = fopen ("f:/ims/debug/nfFeatSet.logCPP", "r"); 00117 if (File == NULL) 00118 { 00119 File = Efopen ("f:/ims/debug/nfFeatSet.logCPP", "w"); 00120 WriteFeatureSet(File, FeatureSet); 00121 } 00122 else 00123 { 00124 fclose (File); 00125 File = Efopen ("f:/ims/debug/nfFeatSet.logCPP", "a"); 00126 } 00127 WriteFeatureSet(File, FeatureSet); 00128 fclose (File); 00129 *--------------------------------------------------------------------*/ 00130 FreeOutlines(Outlines); 00131 return (FeatureSet); 00132 } /* ExtractCharNormFeatures */
Referenced by ExtractCharNormFeatures(), and GetIntCharNormFeatures().