classify/float2int.cpp

Go to the documentation of this file.
00001 
00019 /* =================
00020  Include Files and Type Defines
00021  ==================== */
00022 #include "float2int.h"
00023 #include "normmatch.h"
00024 #include "mfoutline.h"
00025 #include "picofeat.h"
00026 
00027 #define MAX_INT_CHAR_NORM (INT_CHAR_NORM_RANGE - 1)
00028 
00029 /* =================
00030               Public Code
00031  ==================== */
00045 void ClearCharNormArray(INT_TEMPLATES Templates,
00046                         CLASS_NORMALIZATION_ARRAY CharNormArray) {
00047   int i;
00048 
00049   for (i = 0; i < NumClassesIn (Templates); i++) {
00050     CharNormArray[i] = 0;
00051   }
00052 
00053 }                                /* ClearCharNormArray */
00054 
00055 
00071 void ComputeIntCharNormArray(FEATURE NormFeature,
00072                              INT_TEMPLATES Templates,
00073                              CLASS_NORMALIZATION_ARRAY CharNormArray) {
00074   int i;
00075   int NormAdjust;
00076 
00077   for (i = 0; i < NumClassesIn (Templates); i++) {
00078     NormAdjust = (int) (INT_CHAR_NORM_RANGE *
00079       ComputeNormMatch (ClassIdForIndex (Templates, i),
00080       NormFeature, FALSE));
00081     if (NormAdjust < 0)
00082       NormAdjust = 0;
00083     else if (NormAdjust > MAX_INT_CHAR_NORM)
00084       NormAdjust = MAX_INT_CHAR_NORM;
00085 
00086     CharNormArray[i] = NormAdjust;
00087   }
00088 
00089 }                                /* ComputeIntCharNormArray */
00090 
00091 
00092 /*
00093 \param Features      Floating point pico-features to be converted
00094 \param IntFeatures   Array to put converted features into
00095 \return none (results are returned in IntFeatures)
00096 
00097 \brief Converts each floating point pico-feature
00098 in Features into integer format and saves it into IntFeatures.
00099 \note Exceptions: none
00100 \date Wed Feb 20 10:58:45 1991, DSJ, Created.
00101 */
00102 void ComputeIntFeatures(FEATURE_SET Features, INT_FEATURE_ARRAY IntFeatures) { 
00103   int Fid;
00104   FEATURE Feature;
00105   FLOAT32 YShift;
00106 
00107   if (NormMethod == baseline)
00108     YShift = BASELINE_Y_SHIFT;
00109   else
00110     YShift = Y_SHIFT;
00111 
00112   for (Fid = 0; Fid < NumFeaturesIn (Features); Fid++) {
00113     Feature = FeatureIn (Features, Fid);
00114 
00115     IntFeatures[Fid].X = BucketFor (ParamOf (Feature, PicoFeatX),
00116       X_SHIFT, INT_FEAT_RANGE);
00117     IntFeatures[Fid].Y = BucketFor (ParamOf (Feature, PicoFeatY),
00118       YShift, INT_FEAT_RANGE);
00119     IntFeatures[Fid].Theta = CircBucketFor (ParamOf (Feature, PicoFeatDir),
00120       ANGLE_SHIFT, INT_FEAT_RANGE);
00121     IntFeatures[Fid].CP_misses = 0;
00122   }
00123 }                                /* ComputeIntFeatures */

Generated on Wed Feb 28 19:49:10 2007 for Tesseract by  doxygen 1.5.1