classify/normfeat.cpp

Go to the documentation of this file.
00001 
00020 /* =================
00021           Include Files and Type Defines
00022  ==================== */
00023 #include "normfeat.h"
00024 #include "mfoutline.h"
00025 #include "intfx.h"
00026 
00027 #include "ocrfeatures.h"         //Debug
00028 #include <stdio.h>               //Debug
00029 #include "efio.h"                //Debug
00030 //#include "christydbg.h"
00031 
00032 /* =================
00033  Global Data Definitions and Declarations
00034  ==================== */
00035 /* =================
00036               Public Code
00037  ==================== */
00038 /* =============================== */
00049 FLOAT32 ActualOutlineLength(FEATURE Feature) { 
00050   return (ParamOf (Feature, CharNormLength) * LENGTH_COMPRESSION);
00051 
00052 }                                /* ActualOutlineLength */
00053 
00054 
00055 /* =============================== */
00072 FEATURE_SET ExtractCharNormFeatures(TBLOB *Blob, LINE_STATS *LineStats) { 
00073   FEATURE_SET FeatureSet;
00074   FEATURE Feature;
00075   FLOAT32 Scale;
00076   FLOAT32 Baseline;
00077   LIST Outlines;
00078   INT_FEATURE_ARRAY blfeatures;
00079   INT_FEATURE_ARRAY cnfeatures;
00080   INT_FX_RESULT_STRUCT FXInfo;
00081 
00082   /* allocate the feature and feature set - note that there is always one
00083      and only one char normalization feature for any blob */
00084   FeatureSet = NewFeatureSet (1);
00085   Feature = NewFeature (&CharNormDesc);
00086   AddFeature(FeatureSet, Feature); 
00087 
00088   /* compute the normalization statistics for this blob */
00089   Outlines = ConvertBlob (Blob);
00090   /*---------Debug--------------------------------------------------*
00091   OFile = fopen ("f:/ims/debug/nfOutline.logCPP", "r");
00092   if (OFile == NULL)
00093   {
00094     OFile = Efopen ("f:/ims/debug/nfOutline.logCPP", "w");
00095     WriteOutlines(OFile, Outlines);
00096   }
00097   else
00098   {
00099     fclose (OFile);
00100     OFile = Efopen ("f:/ims/debug/nfOutline.logCPP", "a");
00101   }
00102   WriteOutlines(OFile, Outlines);
00103   fclose (OFile);
00104   *--------------------------------------------------------------------*/
00105 
00106   ExtractIntFeat(Blob, blfeatures, cnfeatures, &FXInfo);
00107   Baseline = BaselineAt (LineStats, FXInfo.Xmean);
00108   Scale = ComputeScaleFactor (LineStats);
00109   ParamOf (Feature, CharNormY) = (FXInfo.Ymean - Baseline) * Scale;
00110   ParamOf (Feature, CharNormLength) =
00111     FXInfo.Length * Scale / LENGTH_COMPRESSION;
00112   ParamOf (Feature, CharNormRx) = FXInfo.Rx * Scale;
00113   ParamOf (Feature, CharNormRy) = FXInfo.Ry * Scale;
00114 
00115   /*---------Debug--------------------------------------------------*
00116   File = fopen ("f:/ims/debug/nfFeatSet.logCPP", "r");
00117   if (File == NULL)
00118   {
00119     File = Efopen ("f:/ims/debug/nfFeatSet.logCPP", "w");
00120     WriteFeatureSet(File, FeatureSet);
00121   }
00122   else
00123   {
00124     fclose (File);
00125     File = Efopen ("f:/ims/debug/nfFeatSet.logCPP", "a");
00126   }
00127   WriteFeatureSet(File, FeatureSet);
00128   fclose (File);
00129   *--------------------------------------------------------------------*/
00130   FreeOutlines(Outlines); 
00131   return (FeatureSet);
00132 }                                /* ExtractCharNormFeatures */

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