tesseract  3.04.00
normfeat.cpp
Go to the documentation of this file.
1 /******************************************************************************
2  ** Filename: normfeat.c
3  ** Purpose: Definition of char normalization features.
4  ** Author: Dan Johnson
5  ** History: 12/14/90, DSJ, Created.
6  **
7  ** (c) Copyright Hewlett-Packard Company, 1988.
8  ** Licensed under the Apache License, Version 2.0 (the "License");
9  ** you may not use this file except in compliance with the License.
10  ** You may obtain a copy of the License at
11  ** http://www.apache.org/licenses/LICENSE-2.0
12  ** Unless required by applicable law or agreed to in writing, software
13  ** distributed under the License is distributed on an "AS IS" BASIS,
14  ** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15  ** See the License for the specific language governing permissions and
16  ** limitations under the License.
17  ******************************************************************************/
21 #include "normfeat.h"
22 
23 #include "intfx.h"
24 #include "featdefs.h"
25 #include "mfoutline.h"
26 
31 // Return the length of the outline in baseline normalized form.
33  return (Feature->Params[CharNormLength] * LENGTH_COMPRESSION);
34 }
35 
36 
37 /*---------------------------------------------------------------------------*/
38 // Return the character normalization feature for a blob.
39 //
40 // The features returned are in a scale where the x-height has been
41 // normalized to live in the region y = [-0.25 .. 0.25]. Example ranges
42 // for English below are based on the Linux font collection on 2009-12-04:
43 //
44 // Params[CharNormY]
45 // The y coordinate of the grapheme's centroid.
46 // English: [-0.27, 0.71]
47 //
48 // Params[CharNormLength]
49 // The length of the grapheme's outline (tiny segments discarded),
50 // divided by 10.0=LENGTH_COMPRESSION.
51 // English: [0.16, 0.85]
52 //
53 // Params[CharNormRx]
54 // The radius of gyration about the x axis, as measured from CharNormY.
55 // English: [0.011, 0.34]
56 //
57 // Params[CharNormRy]
58 // The radius of gyration about the y axis, as measured from
59 // the x center of the grapheme's bounding box.
60 // English: [0.011, 0.31]
61 //
63  FEATURE_SET feature_set = NewFeatureSet(1);
64  FEATURE feature = NewFeature(&CharNormDesc);
65 
66  feature->Params[CharNormY] =
68  feature->Params[CharNormLength] =
70  feature->Params[CharNormRx] = MF_SCALE_FACTOR * fx_info.Rx;
71  feature->Params[CharNormRy] = MF_SCALE_FACTOR * fx_info.Ry;
72 
73  AddFeature(feature_set, feature);
74 
75  return feature_set;
76 } /* ExtractCharNormFeatures */
const int kBlnBaselineOffset
Definition: normalis.h:29
FEATURE_SET ExtractCharNormFeatures(const INT_FX_RESULT_STRUCT &fx_info)
Definition: normfeat.cpp:62
#define LENGTH_COMPRESSION
Definition: normfeat.h:26
const FEATURE_DESC_STRUCT CharNormDesc
BOOL8 AddFeature(FEATURE_SET FeatureSet, FEATURE Feature)
Definition: ocrfeatures.cpp:35
FEATURE_SET NewFeatureSet(int NumFeatures)
FLOAT32 ActualOutlineLength(FEATURE Feature)
Definition: normfeat.cpp:32
FLOAT32 Params[1]
Definition: ocrfeatures.h:65
FEATURE NewFeature(const FEATURE_DESC_STRUCT *FeatureDesc)
#define MF_SCALE_FACTOR
Definition: mfoutline.h:63
float FLOAT32
Definition: host.h:111