tesseract v5.3.3.20231005
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 **
6 ** (c) Copyright Hewlett-Packard Company, 1988.
7 ** Licensed under the Apache License, Version 2.0 (the "License");
8 ** you may not use this file except in compliance with the License.
9 ** You may obtain a copy of the License at
10 ** http://www.apache.org/licenses/LICENSE-2.0
11 ** Unless required by applicable law or agreed to in writing, software
12 ** distributed under the License is distributed on an "AS IS" BASIS,
13 ** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 ** See the License for the specific language governing permissions and
15 ** limitations under the License.
16 ******************************************************************************/
17
18#include "normfeat.h"
19
20#include "featdefs.h"
21#include "intfx.h"
22#include "mfoutline.h"
23
24namespace tesseract {
25
28 return (Feature->Params[CharNormLength] * LENGTH_COMPRESSION);
29}
30
57 auto feature_set = new FEATURE_SET_STRUCT(1);
58 auto feature = new FEATURE_STRUCT(&CharNormDesc);
59
60 feature->Params[CharNormY] = MF_SCALE_FACTOR * (fx_info.Ymean - kBlnBaselineOffset);
61 feature->Params[CharNormLength] = MF_SCALE_FACTOR * fx_info.Length / LENGTH_COMPRESSION;
62 feature->Params[CharNormRx] = MF_SCALE_FACTOR * fx_info.Rx;
63 feature->Params[CharNormRy] = MF_SCALE_FACTOR * fx_info.Ry;
64
65 AddFeature(feature_set, feature);
66
67 return feature_set;
68} /* ExtractCharNormFeatures */
69
70} // namespace tesseract
#define LENGTH_COMPRESSION
Definition: normfeat.h:26
FEATURE_SET ExtractCharNormFeatures(const INT_FX_RESULT_STRUCT &fx_info)
Definition: normfeat.cpp:56
const float MF_SCALE_FACTOR
Definition: mfoutline.h:61
bool AddFeature(FEATURE_SET FeatureSet, FEATURE Feature)
Definition: ocrfeatures.cpp:40
@ CharNormLength
Definition: normfeat.h:30
@ CharNormRy
Definition: normfeat.h:30
@ CharNormY
Definition: normfeat.h:30
@ CharNormRx
Definition: normfeat.h:30
const FEATURE_DESC_STRUCT CharNormDesc
float ActualOutlineLength(FEATURE Feature)
Definition: normfeat.cpp:27
const int kBlnBaselineOffset
Definition: normalis.h:34
std::vector< float > Params
Definition: ocrfeatures.h:66