classify/outfeat.h File Reference

#include "ocrfeatures.h"
#include "fpoint.h"
#include "mfoutline.h"

Go to the source code of this file.

Defines

Enumerations

Functions

Variables


Define Documentation

#define MAX_OUTLINE_FEATURES   (100)

Definition at line 40 of file outfeat.h.


Enumeration Type Documentation

enum OUTLINE_FEAT_PARAM_NAME

Info on one Outline feature ??

Enumerator:
OutlineFeatX 
OutlineFeatY 
OutlineFeatLength 
OutlineFeatDir 

Definition at line 33 of file outfeat.h.


Function Documentation

void AddOutlineFeatureToSet ( FPOINT Start,
FPOINT End,
FEATURE_SET  FeatureSet 
)

Computes the midpoint between Start and End to obtain the x,y position of the outline-feature.

Parameters:
Start Starting point of outline-feature
End Ending point of outline-feature
FeatureSet Set to add outline-feature to
Returns:
none (results are placed in FeatureSet)
It also computes the direction from Start to End as the direction of the outline-feature and the distance from Start to End as the length of the outline-feature.

This feature is then inserted into the next feature slot in FeatureSet.

Note:
Exceptions: none
Date:
11/13/90, DSJ, Created.

Definition at line 173 of file outfeat.cpp.

References AddFeature(), AverageOf, DistanceBetween, NewFeature(), NormalizedAngleFrom(), OutlineFeatDesc, OutlineFeatDir, OutlineFeatLength, OutlineFeatX, OutlineFeatY, ParamOf, Xof, and Yof.

Referenced by ConvertToOutlineFeatures().

00175                                                     {
00176   FEATURE Feature;
00177 
00178   Feature = NewFeature (&OutlineFeatDesc);
00179   ParamOf (Feature, OutlineFeatDir) = NormalizedAngleFrom (Start, End, 1.0);
00180   ParamOf (Feature, OutlineFeatX) = AverageOf (Xof (*Start), Xof (*End));
00181   ParamOf (Feature, OutlineFeatY) = AverageOf (Yof (*Start), Yof (*End));
00182   ParamOf (Feature, OutlineFeatLength) = DistanceBetween (*Start, *End);
00183   AddFeature(FeatureSet, Feature); 
00184 
00185 }                                /* AddOutlineFeatureToSet */

void ConvertToOutlineFeatures ( MFOUTLINE  Outline,
FEATURE_SET  FeatureSet 
)

Converts each section in the specified outline to a feature described by its x,y position, length and angle.

Parameters:
Outline Outline to extract outline-features from
FeatureSet Set of features to add outline-features to
Returns:
none (results are returned in FeatureSet)
Note:
An edge is hidden if the ending point of the edge is marked as hidden. This situation happens because the order of the outlines is reversed when they are converted from the old format. In the old format, a hidden edge is marked by the starting point for that edge.
FIX: See Patent 5,237,627 for all the details.
Note:
Exceptions: none
Date:
11/13/90, DSJ, Created. 5/24/91, DSJ, Added hidden edge capability.

Definition at line 209 of file outfeat.cpp.

References AddOutlineFeatureToSet(), CopyPoint, DegenerateOutline, IsVisible, NextPointAfter, PointAt, and PositionOf.

Referenced by ExtractOutlineFeatures().

00209                                                                          { 
00210   MFOUTLINE Next;
00211   MFOUTLINE First;
00212   FPOINT FeatureStart;
00213   FPOINT FeatureEnd;
00214 
00215   if (DegenerateOutline (Outline))
00216     return;
00217 
00218   First = Outline;
00219   Next = First;
00220   do {
00221     CopyPoint (PositionOf (PointAt (Next)), FeatureStart);
00222     Next = NextPointAfter (Next);
00223 
00224     /* Note that an edge is hidden if the ending point of the edge is
00225        marked as hidden.  This situation happens because the order of
00226        the outlines is reversed when they are converted from the old
00227        format.  In the old format, a hidden edge is marked by the
00228        starting point for that edge. */
00229     if (IsVisible (PointAt (Next))) {
00230       CopyPoint (PositionOf (PointAt (Next)), FeatureEnd);
00231       AddOutlineFeatureToSet(&FeatureStart, &FeatureEnd, FeatureSet); 
00232     }
00233   }
00234   while (Next != First);
00235 }                                /* ConvertToOutlineFeatures */

FEATURE_SET ExtractOutlineFeatures ( TBLOB Blob,
LINE_STATS LineStats 
)

Convert each segment in the outline to a feature.

Parameters:
Blob Blob to extract pico-features from
LineStats Statistics on text row blob is in
Returns:
Outline-features for Blob.
Note:
Exceptions: none
Date:
11/13/90, DSJ, Created. 05/24/91, DSJ, Updated for either char or baseline normalize.

Definition at line 77 of file outfeat.cpp.

References baseline, ConvertBlob(), ConvertToOutlineFeatures(), cprintf(), first, FreeOutlines(), iterate, MAX_OUTLINE_FEATURES, NewFeatureSet(), NormalizeOutlines(), NormalizeOutlineX(), NormMethod, NULL, and Outline.

Referenced by MakeNewAdaptedClass().

00077                                                                        { 
00078   LIST Outlines;
00079   LIST RemainingOutlines;
00080   MFOUTLINE Outline;
00081   FEATURE_SET FeatureSet;
00082   FLOAT32 XScale, YScale;
00083 
00084 #ifdef TEXT_VERBOSE
00085   // gets a 'o', see ccmain/tesseractmain.dox
00086   cprintf("o");
00087 #endif
00088   FeatureSet = NewFeatureSet (MAX_OUTLINE_FEATURES);
00089   if (Blob == NULL)
00090     return (FeatureSet);
00091 
00092   Outlines = ConvertBlob (Blob);
00093 
00094   NormalizeOutlines(Outlines, LineStats, &XScale, &YScale); 
00095   RemainingOutlines = Outlines;
00096   iterate(RemainingOutlines) { 
00097     Outline = (MFOUTLINE) first (RemainingOutlines);
00098     /*---------Debug--------------------------------------------------*
00099     OFile = fopen ("f:/ims/debug/ofOutline.logCPP", "r");
00100     if (OFile == NULL)
00101     {
00102       OFile = Efopen ("f:/ims/debug/ofOutline.logCPP", "w");
00103       WriteOutline(OFile, Outline);
00104     }
00105     else
00106     {
00107       fclose (OFile);
00108       OFile = Efopen ("f:/ims/debug/ofOutline.logCPP", "a");
00109     }
00110     WriteOutline(OFile, Outline);
00111     fclose (OFile);
00112     *--------------------------------------------------------------------*/
00113     ConvertToOutlineFeatures(Outline, FeatureSet); 
00114   }
00115   if (NormMethod == baseline)
00116     NormalizeOutlineX(FeatureSet); 
00117   /*---------Debug--------------------------------------------------*
00118   File = fopen ("f:/ims/debug/ofFeatSet.logCPP", "r");
00119   if (File == NULL)
00120   {
00121     File = Efopen ("f:/ims/debug/ofFeatSet.logCPP", "w");
00122     WriteFeatureSet(File, FeatureSet);
00123   }
00124   else
00125   {
00126     fclose (File);
00127     File = Efopen ("f:/ims/debug/ofFeatSet.logCPP", "a");
00128   }
00129   WriteFeatureSet(File, FeatureSet);
00130   fclose (File);
00131   *--------------------------------------------------------------------*/
00132   FreeOutlines(Outlines); 
00133   return (FeatureSet);
00134 }                                /* ExtractOutlineFeatures */

void InitOutlineFXVars (  ) 

Initialize the outline-feature extractor variables that can be tuned without recompiling.

Parameters:
none 
Returns:
none
Note:
Exceptions: none
Date:
11/13/90, DSJ, Created.

Definition at line 147 of file outfeat.cpp.

Referenced by InitAdaptiveClassifierVars().

00147                          { 
00148                                  //once contained a dummy
00149 }                                /* InitOutlineFXVars */

void NormalizeOutlineX ( FEATURE_SET  FeatureSet  ) 

Computes the weighted average x position over all of the outline-features in FeatureSet and then renormalizes the outline-features to force this average to be the x origin (i.e. x=0).

Parameters:
FeatureSet Outline-features to be normalized
Returns:
none (FeatureSet is changed)
Note:
Exceptions: none
Date:
11/13/90, DSJ, Created.

Definition at line 250 of file outfeat.cpp.

References FeatureIn, NumFeaturesIn, OutlineFeatLength, OutlineFeatX, and ParamOf.

Referenced by ExtractOutlineFeatures().

00250                                                { 
00251   int i;
00252   FEATURE Feature;
00253   FLOAT32 Length;
00254   FLOAT32 TotalX = 0.0;
00255   FLOAT32 TotalWeight = 0.0;
00256   FLOAT32 Origin;
00257 
00258   if (NumFeaturesIn (FeatureSet) <= 0)
00259     return;
00260 
00261   for (i = 0; i < NumFeaturesIn (FeatureSet); i++) {
00262     Feature = FeatureIn (FeatureSet, i);
00263     Length = ParamOf (Feature, OutlineFeatLength);
00264     TotalX += ParamOf (Feature, OutlineFeatX) * Length;
00265     TotalWeight += Length;
00266   }
00267   Origin = TotalX / TotalWeight;
00268 
00269   for (i = 0; i < NumFeaturesIn (FeatureSet); i++) {
00270     Feature = FeatureIn (FeatureSet, i);
00271     ParamOf (Feature, OutlineFeatX) -= Origin;
00272   }
00273 }                                /* NormalizeOutlineX */


Variable Documentation

FEATURE_DESC_STRUCT OutlineFeatDesc

Referenced by AddOutlineFeatureToSet().


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