Tesseract  3.02
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
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  INT_FEATURE_ARRAY blfeatures;
67  INT_FEATURE_ARRAY cnfeatures;
68  INT_FX_RESULT_STRUCT FXInfo;
69 
70  ExtractIntFeat(blob, denorm, blfeatures, cnfeatures, &FXInfo);
71 
72  feature->Params[CharNormY] =
74  feature->Params[CharNormLength] =
76  feature->Params[CharNormRx] = MF_SCALE_FACTOR * FXInfo.Rx;
77  feature->Params[CharNormRy] = MF_SCALE_FACTOR * FXInfo.Ry;
78 
79  AddFeature(feature_set, feature);
80 
81  return feature_set;
82 } /* ExtractCharNormFeatures */