Tesseract  3.02
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
float2int.cpp
Go to the documentation of this file.
1 /******************************************************************************
2  ** Filename: float2int.c
3  ** Purpose: Routines for converting float features to int features
4  ** Author: Dan Johnson
5  ** History: Wed Mar 13 07:47:48 1991, 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  ******************************************************************************/
18 /*-----------------------------------------------------------------------------
19  Include Files and Type Defines
20 -----------------------------------------------------------------------------*/
21 #include "float2int.h"
22 #include "normmatch.h"
23 #include "mfoutline.h"
24 #include "classify.h"
25 #include "helpers.h"
26 #include "picofeat.h"
27 
28 #define MAX_INT_CHAR_NORM (INT_CHAR_NORM_RANGE - 1)
29 
30 /*-----------------------------------------------------------------------------
31  Public Code
32 -----------------------------------------------------------------------------*/
33 /*---------------------------------------------------------------------------*/
34 namespace tesseract {
35 
48 void Classify::ClearCharNormArray(uinT8* char_norm_array) {
49  memset(char_norm_array, 0, sizeof(*char_norm_array) * unicharset.size());
50 } /* ClearCharNormArray */
51 
52 
53 /*---------------------------------------------------------------------------*/
70  uinT8* char_norm_array) {
71  for (int i = 0; i < unicharset.size(); i++) {
72  int norm_adjust = static_cast<int>(INT_CHAR_NORM_RANGE *
73  ComputeNormMatch(i, norm_feature, FALSE));
74  char_norm_array[i] = ClipToRange(norm_adjust, 0, MAX_INT_CHAR_NORM);
75  }
76 } /* ComputeIntCharNormArray */
77 
78 
79 /*---------------------------------------------------------------------------*/
95  INT_FEATURE_ARRAY IntFeatures) {
96  int Fid;
97  FEATURE Feature;
98  FLOAT32 YShift;
99 
101  YShift = BASELINE_Y_SHIFT;
102  else
103  YShift = Y_SHIFT;
104 
105  for (Fid = 0; Fid < Features->NumFeatures; Fid++) {
106  Feature = Features->Features[Fid];
107 
108  IntFeatures[Fid].X = BucketFor (Feature->Params[PicoFeatX],
110  IntFeatures[Fid].Y = BucketFor (Feature->Params[PicoFeatY],
111  YShift, INT_FEAT_RANGE);
112  IntFeatures[Fid].Theta = CircBucketFor (Feature->Params[PicoFeatDir],
114  IntFeatures[Fid].CP_misses = 0;
115  }
116 } /* ComputeIntFeatures */
117 } // namespace tesseract