classify/featdefs.cpp File Reference

#include "featdefs.h"
#include "emalloc.h"
#include "danerror.h"
#include "scanutils.h"
#include "variables.h"
#include "sigmenu.h"
#include <string.h>
#include <stdio.h>

Go to the source code of this file.

Defines

Functions

Variables


Define Documentation

#define ILLEGAL_NUM_SETS   3001

Note:
File: featdefs.cpp
Definitions of currently defined feature types.
Author:
Dan Johnson
Date:
Mon May 21 10:26:21 1990, DSJ, Created.
 **	(c) Copyright Hewlett-Packard Company, 1988.
 ** Licensed under the Apache License, Version 2.0 (the "License");
 ** you may not use this file except in compliance with the License.
 ** You may obtain a copy of the License at
 ** http://www.apache.org/licenses/LICENSE-2.0
 ** Unless required by applicable law or agreed to in writing, software
 ** distributed under the License is distributed on an "AS IS" BASIS,
 ** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 ** See the License for the specific language governing permissions and
 ** limitations under the License.

Definition at line 34 of file featdefs.cpp.

Referenced by ReadCharDescription().

#define MAX_OUTLINE_FEATURES   100

Definition at line 37 of file featdefs.cpp.

Referenced by ExtractOutlineFeatures().

#define PICO_FEATURE_LENGTH   0.05

Definition at line 36 of file featdefs.cpp.

Referenced by InitPicoFXVars().


Function Documentation

EndParamDesc DefineFeature ( PicoFeatDesc  ,
,
,
,
MAX_UINT8  ,
"Pico"  ,
"pf"  ,
PicoFeatParams   
)

EndParamDesc DefineParam ( ,
,
0.  0,
1.  0 
)

DefineParam ( ,
,
-0.  5,
0.  5 
)

EndParamDesc CharNormParams DefineParam ( ,
,
0.  0,
1.  0 
)

EndParamDesc CharNormParams DefineParam ( ,
,
-0.  25,
0.  75 
)

void FreeCharDescription ( CHAR_DESC  CharDesc  ) 

Release the memory consumed by the specified character description and all of the features in that description.

Parameters:
CharDesc Character description to be deallocated
Returns:
none
Note:
Exceptions: none
Date:
Wed May 23 13:52:19 1990, DSJ, Created.

Definition at line 115 of file featdefs.cpp.

References Efree(), FeaturesOfType, FreeFeatureSet(), and NumFeatureSetsIn.

Referenced by LearnBlob().

00115                                              {
00116   int i;
00117 
00118   if (CharDesc) {
00119     for (i = 0; i < NumFeatureSetsIn (CharDesc); i++)
00120       FreeFeatureSet (FeaturesOfType (CharDesc, i));
00121     Efree(CharDesc);
00122   }
00123 }                                /* FreeCharDescription */

CHAR_DESC NewCharDescription (  ) 

Allocate a new character description, initialize its feature sets to be empty, and return it.

Parameters:
none 
Returns:
New character description structure.
Note:
Exceptions: none
Date:
Wed May 23 15:27:10 1990, DSJ, Created.

Definition at line 135 of file featdefs.cpp.

References Emalloc(), FeaturesOfType, NULL, NumFeaturesDefined, and NumFeatureSetsIn.

Referenced by ExtractFlexFeatures(), and ReadCharDescription().

00135                                {
00136   CHAR_DESC CharDesc;
00137   int i;
00138 
00139   CharDesc = (CHAR_DESC) Emalloc (sizeof (CHAR_DESC_STRUCT));
00140   NumFeatureSetsIn (CharDesc) = NumFeaturesDefined ();
00141 
00142   for (i = 0; i < NumFeatureSetsIn (CharDesc); i++)
00143     FeaturesOfType (CharDesc, i) = NULL;
00144 
00145   return (CharDesc);
00146 
00147 }                                /* NewCharDescription */

CHAR_DESC ReadCharDescription ( FILE *  File  ) 

Read a character description from File, and return a data structure containing this information.

Parameters:
File Open text file to read character description from
Returns:
Character description read from File.
The data is formatted as follows:
    NumberOfSets
   	    ShortNameForSet1 Set1
        ShortNameForSet2 Set2
        ...
Note:
Exceptions: ILLEGAL_NUM_SETS
Date:
Wed May 23 17:32:48 1990, DSJ, Created.

Definition at line 201 of file featdefs.cpp.

References DefinitionOf, DoError(), FEAT_NAME_SIZE, FeaturesOfType, fscanf(), ILLEGAL_NUM_SETS, NewCharDescription(), NumFeaturesDefined, ReadFeatureSet(), and ShortNameToFeatureType().

Referenced by ReadTrainingSamples().

00201                                           {
00202   int NumSetsToRead;
00203   char ShortName[FEAT_NAME_SIZE];
00204   CHAR_DESC CharDesc;
00205   int Type;
00206 
00207   if (fscanf (File, "%d", &NumSetsToRead) != 1 ||
00208     NumSetsToRead < 0 || NumSetsToRead > NumFeaturesDefined ())
00209     DoError (ILLEGAL_NUM_SETS, "Illegal number of feature sets");
00210 
00211   CharDesc = NewCharDescription ();
00212   for (; NumSetsToRead > 0; NumSetsToRead--) {
00213     fscanf (File, "%s", ShortName);
00214     Type = ShortNameToFeatureType (ShortName);
00215     FeaturesOfType (CharDesc, Type) =
00216       ReadFeatureSet (File, DefinitionOf (Type));
00217   }
00218   return (CharDesc);
00219 
00220 }                                // ReadCharDescription

int ShortNameToFeatureType ( const char *  ShortName  ) 

Search thru all features currently defined and return the feature type for the feature with the specified short name.

Parameters:
ShortName Short name of a feature type
Returns:
Feature type which corresponds to ShortName.
Trap an error if the specified name is not found.
Note:
Exceptions: ILLEGAL_SHORT_NAME
Date:
Wed May 23 15:36:05 1990, DSJ, Created.
Note:
param was made const for v1.03

Definition at line 236 of file featdefs.cpp.

References DefinitionOf, DoError(), ILLEGAL_SHORT_NAME, NumFeaturesDefined, and ShortNameOf.

Referenced by ReadCharDescription(), ReadTrainingSamples(), SetUpForClustering(), and WriteTrainingSamples().

00236                                                   {
00237   int i;
00238 
00239   for (i = 0; i < NumFeaturesDefined (); i++)
00240     if (!strcmp (ShortNameOf (DefinitionOf (i)), ShortName))
00241       return (i);
00242   DoError (ILLEGAL_SHORT_NAME, "Illegal short name for a feature");
00243   return 0;
00244 
00245 }                                // ShortNameToFeatureType

EndParamDesc CharNormParams StartParamDesc ( OutlineFeatParams   ) 

StartParamDesc ( PicoFeatParams   ) 

StartParamDesc ( MicroFeatureParams   ) 

---------------------------------------------------------------------------- Global Data Definitions and Declarations ----------------------------------------------------------------------------

void WriteCharDescription ( FILE *  File,
CHAR_DESC  CharDesc 
)

Write a textual representation of CharDesc to File.

Parameters:
File Open text file to write CharDesc to
CharDesc Character description to write to File
Returns:
none
The format used is to write out the number of feature sets which will be written followed by a representation of each feature set.

Each set starts with the short name for that feature followed by a description of the feature set. Feature sets which are not present are not written.

Note:
Exceptions: none
Date:
Wed May 23 17:21:18 1990, DSJ, Created.

Definition at line 167 of file featdefs.cpp.

References DefinitionOf, FeaturesOfType, NumFeatureSetsIn, ShortNameOf, and WriteFeatureSet().

Referenced by LearnBlob().

00167                                                           {
00168   int Type;
00169   int NumSetsToWrite = 0;
00170 
00171   for (Type = 0; Type < NumFeatureSetsIn (CharDesc); Type++)
00172     if (FeaturesOfType (CharDesc, Type))
00173       NumSetsToWrite++;
00174 
00175   fprintf (File, " %d\n", NumSetsToWrite);
00176   for (Type = 0; Type < NumFeatureSetsIn (CharDesc); Type++)
00177   if (FeaturesOfType (CharDesc, Type)) {
00178     fprintf (File, "%s ", ShortNameOf (DefinitionOf (Type)));
00179     WriteFeatureSet (File, FeaturesOfType (CharDesc, Type));
00180   }
00181 }                                /* WriteCharDescription */


Variable Documentation

EndParamDesc CharNorm

Definition at line 76 of file featdefs.cpp.

EndParamDesc cn

Definition at line 76 of file featdefs.cpp.

EndParamDesc CharNormParams OutlineFeatParams FEATURE_DEFS_STRUCT FeatureDefs

Initial value:

Definition at line 93 of file featdefs.cpp.

EndParamDesc CharNormParams MAX_OUTLINE_FEATURES

Definition at line 87 of file featdefs.cpp.

mf

Definition at line 53 of file featdefs.cpp.

Micro

Definition at line 53 of file featdefs.cpp.

EndParamDesc CharNormParams of

Definition at line 87 of file featdefs.cpp.

EndParamDesc CharNormParams Outline

Definition at line 87 of file featdefs.cpp.

Referenced by BlobMicroFeatures(), ComputeOutlineStats(), ConvertOutline(), ConvertOutlines(), ExtractOutlineFeatures(), ExtractPicoFeatures(), FreeMFOutline(), NormalizeOutlines(), and NumOutlinesInBlob().

MicroFeatureParams FLOAT32 PicoFeatureLength = PICO_FEATURE_LENGTH

Definition at line 57 of file featdefs.cpp.

Referenced by ConvertSegmentToPicoFeat(), and InitPicoFXVars().


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