classify/normfeat.cpp File Reference

#include "normfeat.h"
#include "mfoutline.h"
#include "intfx.h"
#include "ocrfeatures.h"
#include <stdio.h>
#include "efio.h"

Go to the source code of this file.

Functions


Function Documentation

FLOAT32 ActualOutlineLength ( FEATURE  Feature  ) 

Computes the length that the outline would have been if it were baseline normalized instead of character normalized.

Parameters:
Feature Normalization feature
Returns:
Baseline normalized length of outline.
Note:
Exceptions: none
Date:
Thu Dec 20 14:50:57 1990, DSJ, Created.

Definition at line 49 of file normfeat.cpp.

References CharNormLength, LENGTH_COMPRESSION, and ParamOf.

00049                                              { 
00050   return (ParamOf (Feature, CharNormLength) * LENGTH_COMPRESSION);
00051 
00052 }                                /* ActualOutlineLength */

FEATURE_SET ExtractCharNormFeatures ( TBLOB Blob,
LINE_STATS LineStats 
)

Compute a feature whose parameters describe how a character will be affected by the character normalization algorithm.

Parameters:
Blob Blob to extract char norm feature from
LineStats Statistics on text row blob is in
Returns:
Character normalization feature for Blob.
The feature parameters are:

Definition at line 72 of file normfeat.cpp.

References AddFeature(), BaselineAt, CharNormDesc, CharNormLength, CharNormRx, CharNormRy, CharNormY, ComputeScaleFactor, ConvertBlob(), ExtractIntFeat(), FreeOutlines(), FXInfo, INT_FX_RESULT_STRUCT::Length, LENGTH_COMPRESSION, NewFeature(), NewFeatureSet(), ParamOf, INT_FX_RESULT_STRUCT::Rx, INT_FX_RESULT_STRUCT::Ry, INT_FX_RESULT_STRUCT::Xmean, and INT_FX_RESULT_STRUCT::Ymean.

00072                                                                         { 
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:21 2007 for Tesseract by  doxygen 1.5.1