classify/intproto.h File Reference

#include "matchdefs.h"
#include "protos.h"
#include "callcpp.h"

Go to the source code of this file.

Classes

Defines

Typedefs

Functions


Define Documentation

#define ANGLE_SHIFT   (0.0)

Coordinate system offsets for each table parameter

Definition at line 35 of file intproto.h.

Referenced by AddProtoToProtoPruner(), and ComputeIntFeatures().

#define BITS_PER_CP_VECTOR   (CLASSES_PER_CP * NUM_BITS_PER_CLASS)

Definition at line 60 of file intproto.h.

#define BITS_PER_WERD   (8 * sizeof (UINT32))

Definition at line 41 of file intproto.h.

#define CLASSES_PER_CP   32

FIX:

Definition at line 56 of file intproto.h.

#define CLASSES_PER_CP_WERD   (CLASSES_PER_CP / NUM_BITS_PER_CLASS)

Definition at line 58 of file intproto.h.

Referenced by feature_pruner().

#define ClassForClassId ( T,
 )     (ClassForIndex (T, IndexForClassId (T, C)))

Definition at line 232 of file intproto.h.

Referenced by AdaptToChar(), AddNewResult(), AmbigClassifier(), BaselineClassifier(), CharNormClassifier(), compare_tess_blobs(), GetBestRatingFor(), MakeNewAdaptedClass(), MakeNewTemporaryConfig(), and ShowBestMatchFor().

#define ClassForIndex ( T,
 )     ((T)->Class[I])

Definition at line 231 of file intproto.h.

Referenced by AddIntClass(), BaselineClassifier(), free_int_templates(), make_config_pruner(), PrintAdaptedTemplates(), prune_configs(), ReadIntTemplates(), WriteAdaptedTemplates(), WriteIntTemplates(), and WritePFFMTable().

#define ClassIdForIndex ( T,
 )     ((T)->ClassIdFor[I])

Definition at line 227 of file intproto.h.

Referenced by AddIntClass(), ClassPruner(), ComputeIntCharNormArray(), InitAdaptiveClassifier(), NewIntTemplates(), PrintAdaptedTemplates(), and WritePFFMTable().

#define ClassPrunersFor (  )     ((T)->ClassPruner)

Definition at line 233 of file intproto.h.

Referenced by ClassPruner(), and feature_pruner().

#define CLIP_MATCH_EVIDENCE   0x020

Definition at line 246 of file intproto.h.

#define ClipMatchEvidenceOn (  )     ((D) & CLIP_MATCH_EVIDENCE)

Definition at line 254 of file intproto.h.

Referenced by IMDisplayFeatureDebugInfo(), and IMDisplayProtoDebugInfo().

#define CPrunerBitIndexFor (  )     (((I) % CLASSES_PER_CP) % CLASSES_PER_CP_WERD)

Definition at line 237 of file intproto.h.

#define CPrunerFor ( T,
 )     ((T)->ClassPruner [CPrunerIdFor (I)])

Definition at line 235 of file intproto.h.

Referenced by AddProtoToClassPruner().

#define CPrunerIdFor (  )     ((I) / CLASSES_PER_CP)

Definition at line 234 of file intproto.h.

#define CPrunerMaskFor ( L,
 )     (((L)+1) << CPrunerBitIndexFor (I) * NUM_BITS_PER_CLASS)

Definition at line 238 of file intproto.h.

Referenced by AddProtoToClassPruner().

#define CPrunerWordIndexFor (  )     (((I) % CLASSES_PER_CP) / CLASSES_PER_CP_WERD)

Definition at line 236 of file intproto.h.

Referenced by AddProtoToClassPruner().

#define DISPLAY_FEATURE_MATCHES   0x002

Definition at line 242 of file intproto.h.

#define DISPLAY_PROTO_MATCHES   0x004

Definition at line 243 of file intproto.h.

#define DisplayFeatureMatchesOn (  )     ((D) & DISPLAY_FEATURE_MATCHES)

Definition at line 250 of file intproto.h.

Referenced by IntegerMatcher().

#define DisplayProtoMatchesOn (  )     ((D) & DISPLAY_PROTO_MATCHES)

Definition at line 251 of file intproto.h.

Referenced by IntegerMatcher().

#define IndexForClassId ( T,
 )     ((T)->IndexFor[C])

Definition at line 228 of file intproto.h.

Referenced by AdaptToChar(), AddIntClass(), AddProtoToClassPruner(), AmbigClassifier(), BaselineClassifier(), CharNormClassifier(), feature_pruner(), GetBestRatingFor(), InitAdaptiveClassifier(), MakeNewAdaptedClass(), MakeNewTemporaryConfig(), MakePermanent(), MakeTempProtoPerm(), NewIntTemplates(), prune_configs(), and ShowBestMatchFor().

#define IndexForProto (  )     (P % PROTOS_PER_PROTO_SET)

Definition at line 212 of file intproto.h.

Referenced by AddProtoToProtoPruner(), and RenderIntProto().

#define INT_CHAR_NORM_RANGE   256

definitions of integer features

Definition at line 173 of file intproto.h.

Referenced by ComputeIntCharNormArray(), RenderIntFeature(), and RenderIntProto().

#define LegalClassId (  )     ((C) > 0 && (C) < MAX_CLASS_ID)

Definition at line 229 of file intproto.h.

Referenced by AdaptToChar(), AddAdaptedClass(), AddIntClass(), GetBestRatingFor(), and ShowBestMatchFor().

#define LengthForConfigId ( C,
 )     ((C)->ConfigLengths[c])

Definition at line 217 of file intproto.h.

Referenced by AddIntConfig(), ConvertConfig(), IMDebugFeatureProtoError(), IMNormalizeSumOfEvidences(), and WritePFFMTable().

#define LengthForProtoId ( C,
 )     ((C)->ProtoLengths[P])

Definition at line 216 of file intproto.h.

Referenced by AddIntProto(), ConvertConfig(), ConvertProto(), FindGoodProtos(), IMDebugFeatureProtoError(), IMDisplayProtoDebugInfo(), IMUpdateSumOfProtoEvidences(), IMUpdateTablesForFeature(), and RenderIntProto().

#define MatchDebuggingOn (  )     (D)

Definition at line 248 of file intproto.h.

Referenced by FindBadFeatures(), FindGoodProtos(), IntegerMatcher(), and PruningMatcher().

#define MAX_NUM_CLASS_PRUNERS

Value:

Definition at line 61 of file intproto.h.

Referenced by ReadIntTemplates().

#define MAX_NUM_CONFIGS   32

FIX:

Definition at line 43 of file intproto.h.

Referenced by AddIntConfig(), compare_tess_blobs(), FindBadFeatures(), FindGoodProtos(), free_adapted_class(), IMDisplayFeatureDebugInfo(), InitAdaptiveClassifier(), IntegerMatcher(), MakeNewTemporaryConfig(), NewAdaptedClass(), NewIntClass(), NewLabeledClass(), PruningMatcher(), ReadAdaptedClass(), ReadIntTemplates(), and WriteAdaptedClass().

#define MAX_NUM_INT_FEATURES   512

definitions of integer features

Definition at line 171 of file intproto.h.

Referenced by MakeNewTemporaryConfig(), and SaveFeature().

#define MAX_NUM_PROTO_SETS   (MAX_NUM_PROTOS / PROTOS_PER_PROTO_SET)

Definition at line 48 of file intproto.h.

Referenced by NewIntClass(), and ReadIntTemplates().

#define MAX_NUM_PROTOS   256

FIX:

Definition at line 45 of file intproto.h.

Referenced by AddIntProto(), compare_tess_blobs(), config_mask_to_proto_mask(), FindBadFeatures(), FindGoodProtos(), IMDisplayFeatureDebugInfo(), InitAdaptiveClassifier(), IntegerMatcher(), MakeNewTemporaryConfig(), NewAdaptedClass(), NewLabeledClass(), ReadAdaptedClass(), and WriteAdaptedClass().

#define MAX_PROTO_INDEX   24

FIX:

Definition at line 40 of file intproto.h.

Referenced by FindBadFeatures(), FindGoodProtos(), IMDisplayFeatureDebugInfo(), and IntegerMatcher().

#define MaxNumClassesIn (  )     (NumClassPrunersIn (T) * CLASSES_PER_CP)

Definition at line 226 of file intproto.h.

Referenced by AddIntClass().

#define MaxNumIntProtosIn (  )     (NumProtoSetsIn (C) * PROTOS_PER_PROTO_SET)

Definition at line 208 of file intproto.h.

Referenced by AddIntProto(), NewIntClass(), ReadIntTemplates(), and WriteIntTemplates().

#define NUM_BITS_PER_CLASS   2

Definition at line 57 of file intproto.h.

#define NUM_CP_BUCKETS   24

FIX:

Definition at line 54 of file intproto.h.

Referenced by ClassPruner(), DoFill(), feature_pruner(), and ReadIntTemplates().

#define NUM_PP_BUCKETS   64

FIX:

Definition at line 52 of file intproto.h.

Referenced by FillPPCircularBits(), FillPPLinearBits(), IMUpdateTablesForFeature(), make_config_pruner(), PMUpdateTablesForFeature(), ReadIntTemplates(), and RenderIntProto().

#define NUM_PP_PARAMS   3

FIX:

Definition at line 50 of file intproto.h.

Referenced by ReadIntTemplates().

#define NumClassesIn (  )     ((T)->NumClasses)

Definition at line 224 of file intproto.h.

Referenced by AddIntClass(), ClassPruner(), ClearCharNormArray(), ComputeIntCharNormArray(), feature_pruner(), free_adapted_templates(), free_int_templates(), InitAdaptiveClassifier(), make_config_pruner(), NewIntTemplates(), PrintAdaptedTemplates(), ReadAdaptedTemplates(), ReadIntTemplates(), WriteAdaptedTemplates(), WriteIntTemplates(), and WritePFFMTable().

#define NumClassPrunersIn (  )     ((T)->NumClassPruners)

Definition at line 225 of file intproto.h.

Referenced by AddIntClass(), ClassPruner(), feature_pruner(), free_int_templates(), NewIntTemplates(), ReadIntTemplates(), and WriteIntTemplates().

#define NumIntConfigsIn (  )     ((C)->NumConfigs)

Definition at line 209 of file intproto.h.

Referenced by AddIntConfig(), AddNewResult(), BaselineClassifier(), FindBadFeatures(), IMClearTables(), IMDebugFeatureProtoError(), IMDisplayFeatureDebugInfo(), IMFindBestMatch(), IMNormalizeSumOfEvidences(), IMUpdateTablesForFeature(), MakeNewTemporaryConfig(), NewIntClass(), PMNormalizeSumOfEvidences(), PMUpdateTablesForFeature(), PrintAdaptedTemplates(), PruningMatcher(), WriteAdaptedTemplates(), and WritePFFMTable().

#define NumIntProtosIn (  )     ((C)->NumProtos)

Definition at line 206 of file intproto.h.

Referenced by AddIntProto(), AddProtoToProtoPruner(), config_mask_to_proto_mask(), ConvertConfig(), ConvertProto(), FindGoodProtos(), IMClearTables(), IMDebugFeatureProtoError(), IMDisplayProtoDebugInfo(), IMUpdateSumOfProtoEvidences(), MakeNewTemporaryConfig(), MakeNewTempProtos(), NewIntClass(), PrintAdaptedTemplates(), and RenderIntProto().

#define NumProtoSetsIn (  )     ((C)->NumProtoSets)

Definition at line 207 of file intproto.h.

Referenced by AddIntProto(), config_mask_to_proto_mask(), free_int_class(), IMDebugFeatureProtoError(), IMDisplayProtoDebugInfo(), IMUpdateSumOfProtoEvidences(), IMUpdateTablesForFeature(), make_config_pruner(), NewIntClass(), PMUpdateTablesForFeature(), ReadIntTemplates(), and WriteIntTemplates().

#define PPrunerBitIndexFor (  )     ((I) % PROTOS_PER_PP_WERD)

Definition at line 220 of file intproto.h.

#define PPrunerMaskFor (  )     (1 << PPrunerBitIndexFor (I))

Definition at line 221 of file intproto.h.

Referenced by RenderIntProto().

#define PPrunerWordIndexFor (  ) 

Value:

Definition at line 218 of file intproto.h.

Referenced by RenderIntProto().

#define PRINT_FEATURE_MATCHES   0x008

Definition at line 244 of file intproto.h.

Referenced by MakeNewTemporaryConfig().

#define PRINT_MATCH_SUMMARY   0x001

Definition at line 241 of file intproto.h.

Referenced by MakeNewTemporaryConfig().

#define PRINT_PROTO_MATCHES   0x010

Definition at line 245 of file intproto.h.

Referenced by MakeNewTemporaryConfig().

#define PrintFeatureMatchesOn (  )     ((D) & PRINT_FEATURE_MATCHES)

Definition at line 252 of file intproto.h.

Referenced by IMUpdateTablesForFeature(), and PMUpdateTablesForFeature().

#define PrintMatchSummaryOn (  )     ((D) & PRINT_MATCH_SUMMARY)

Definition at line 249 of file intproto.h.

Referenced by FindBadFeatures(), FindGoodProtos(), IMDebugFeatureProtoError(), IntegerMatcher(), and PruningMatcher().

#define PrintProtoMatchesOn (  )     ((D) & PRINT_PROTO_MATCHES)

Definition at line 253 of file intproto.h.

Referenced by FindBadFeatures(), FindGoodProtos(), IMDebugFeatureProtoError(), and IntegerMatcher().

#define ProtoForProtoId ( C,
 ) 

Value:

(&((ProtoSetIn (C, SetForProto (P)))-> \
               Protos [IndexForProto (P)]))

Definition at line 214 of file intproto.h.

Referenced by AddIntProto(), ConvertConfig(), and ConvertProto().

#define ProtoPrunerFor (  )     (S->ProtoPruner)

PROTO_SET access macros

Definition at line 203 of file intproto.h.

Referenced by AddIntProto(), and NewIntClass().

#define PROTOS_PER_PP_WERD   BITS_PER_WERD

Definition at line 59 of file intproto.h.

#define PROTOS_PER_PROTO_SET   64

FIX:

Definition at line 47 of file intproto.h.

Referenced by config_mask_to_proto_mask(), IMDebugFeatureProtoError(), IMDisplayProtoDebugInfo(), IMUpdateSumOfProtoEvidences(), IMUpdateTablesForFeature(), make_config_pruner(), NewIntClass(), PMUpdateTablesForFeature(), and ReadIntTemplates().

#define ProtoSetIn ( C,
 )     ((C)->ProtoSets[I])

Definition at line 210 of file intproto.h.

Referenced by AddIntProto(), AddProtoToProtoPruner(), config_mask_to_proto_mask(), free_int_class(), IMDebugFeatureProtoError(), IMDisplayProtoDebugInfo(), IMUpdateSumOfProtoEvidences(), IMUpdateTablesForFeature(), make_config_pruner(), NewIntClass(), PMUpdateTablesForFeature(), ReadIntTemplates(), RenderIntProto(), and WriteIntTemplates().

#define PRUNER_ANGLE   2

Definition at line 32 of file intproto.h.

Referenced by AddProtoToProtoPruner().

#define PRUNER_X   0

Order of params in pruners

Definition at line 30 of file intproto.h.

Referenced by AddProtoToProtoPruner(), and RenderIntProto().

#define PRUNER_Y   1

Definition at line 31 of file intproto.h.

Referenced by AddProtoToProtoPruner(), and RenderIntProto().

#define SetForProto (  )     (P / PROTOS_PER_PROTO_SET)

Definition at line 211 of file intproto.h.

Referenced by AddProtoToProtoPruner(), and RenderIntProto().

#define UnusedClassIdIn ( T,
 )     (IndexForClassId (T,C) == ILLEGAL_CLASS)

Definition at line 230 of file intproto.h.

Referenced by AdaptToChar(), AddAdaptedClass(), AddIntClass(), CreateIntTemplates(), GetBestRatingFor(), and ShowBestMatchFor().

#define WERDS_PER_CONFIG_VEC

Value:

Definition at line 70 of file intproto.h.

Referenced by AddIntProto(), and ReadIntTemplates().

#define WERDS_PER_CP

Value:

Definition at line 68 of file intproto.h.

Referenced by AddIntClass().

#define WERDS_PER_CP_VECTOR   (BITS_PER_CP_VECTOR / BITS_PER_WERD)

Definition at line 63 of file intproto.h.

Referenced by ClassPruner(), feature_pruner(), and ReadIntTemplates().

#define WERDS_PER_PP

Value:

Definition at line 66 of file intproto.h.

Referenced by AddIntProto(), and NewIntClass().

#define WERDS_PER_PP_VECTOR

Value:

Definition at line 64 of file intproto.h.

Referenced by ReadIntTemplates().

#define X_SHIFT   (0.5)

Definition at line 36 of file intproto.h.

Referenced by AddProtoToProtoPruner(), and ComputeIntFeatures().

#define Y_SHIFT   (0.5)

Definition at line 37 of file intproto.h.

Referenced by AddProtoToProtoPruner(), and ComputeIntFeatures().


Typedef Documentation

typedef UINT32(* CLASS_PRUNER)[NUM_CP_BUCKETS][NUM_CP_BUCKETS][WERDS_PER_CP_VECTOR]

Definition at line 83 of file intproto.h.

CLASS_PRUNER_STRUCT

FIX: Holds info for class pruner/operator that works on templates.

(fmg only) Templates->ClassPruner[Pruner] = @CLASS_PRUNER_STRUCT

Definition at line 80 of file intproto.h.

CONFIG_PRUNER

Holds a matrix of CONFIG_PRUNER (training data).

Definition at line 125 of file intproto.h.

typedef struct INT_CLASS_STRUCT * INT_CLASS

INT_FEATURE

Pointer to INT_FEATURE_STRUCT (unit of feature).

Definition at line 191 of file intproto.h.

INT_FEATURE_ARRAY

Array INT_FEATURE_STRUCT (set of features, see Glossary).

Definition at line 197 of file intproto.h.

typedef struct INT_PROTO_STRUCT * INT_PROTO

typedef struct INT_TEMPLATES_STRUCT * INT_TEMPLATES

typedef struct PROTO_SET_STRUCT * PROTO_SET


Function Documentation

int AddIntClass ( INT_TEMPLATES  Templates,
CLASS_ID  ClassId,
INT_CLASS  Class 
)

Adds a new class structure to a set of templates.

Parameters:
Templates Templates to add new class to
ClassId Class id to associate new class with
Class Class data structure to add to templates
Returns:
The class index of the new class.
Note:
Exceptions: none
Date:
Mon Feb 11 11:52:08 1991, DSJ, Created.

Definition at line 289 of file intproto.cpp.

References assert(), ClassForIndex, ClassIdForIndex, Emalloc(), IndexForClassId, LegalClassId, MaxNumClassesIn, NumClassesIn, NumClassPrunersIn, UnusedClassIdIn, and WERDS_PER_CP.

Referenced by AddAdaptedClass(), and CreateIntTemplates().

00289                                                                             { 
00290   int Index;
00291   int Pruner;
00292   UINT32 *Word;
00293 
00294   assert (LegalClassId (ClassId));
00295   assert (UnusedClassIdIn (Templates, ClassId));
00296 
00297   Index = NumClassesIn (Templates);
00298   IndexForClassId (Templates, ClassId) = Index;
00299   ClassIdForIndex (Templates, Index) = ClassId;
00300 
00301   NumClassesIn (Templates)++;
00302   ClassForIndex (Templates, Index) = Class;
00303 
00304   if (NumClassesIn (Templates) > MaxNumClassesIn (Templates)) {
00305     Pruner = NumClassPrunersIn (Templates);
00306     NumClassPrunersIn (Templates)++;
00307     Templates->ClassPruner[Pruner] =
00308       (CLASS_PRUNER) Emalloc (sizeof (CLASS_PRUNER_STRUCT));
00309 
00310     for (Word = (UINT32 *) (Templates->ClassPruner[Pruner]);
00311       Word < (UINT32 *) (Templates->ClassPruner[Pruner]) + WERDS_PER_CP;
00312       *Word++ = 0);
00313   }
00314 
00315   return (Index);
00316 
00317 }                                /* AddIntClass */

int AddIntConfig ( INT_CLASS  Class  ) 

Returns the index of the next free config in Class.

Parameters:
Class Class to add new configuration to
Returns:
Index of next free config.
Note:
Exceptions: none
Date:
Mon Feb 11 14:44:40 1991, DSJ, Created.

Definition at line 329 of file intproto.cpp.

References assert(), LengthForConfigId, MAX_NUM_CONFIGS, and NumIntConfigsIn.

Referenced by CreateIntTemplates(), MakeNewAdaptedClass(), and MakeNewTemporaryConfig().

00329                                   { 
00330   int Index;
00331 
00332   assert (NumIntConfigsIn (Class) < MAX_NUM_CONFIGS);
00333 
00334   Index = NumIntConfigsIn (Class);
00335   NumIntConfigsIn (Class)++;
00336   LengthForConfigId (Class, Index) = 0;
00337   return (Index);
00338 }                                /* AddIntConfig */

int AddIntProto ( INT_CLASS  Class  ) 

Allocates the next free proto in Class and returns its index.

Parameters:
Class Class to add new proto to
Returns:
Proto index of new proto.
Note:
Exceptions: none
Date:
Mon Feb 11 13:26:41 1991, DSJ, Created.

Definition at line 350 of file intproto.cpp.

References Emalloc(), Erealloc(), LengthForProtoId, MAX_NUM_PROTOS, MaxNumIntProtosIn, NO_PROTO, NumIntProtosIn, NumProtoSetsIn, ProtoForProtoId, ProtoPrunerFor, ProtoSetIn, WERDS_PER_CONFIG_VEC, and WERDS_PER_PP.

Referenced by CreateIntTemplates(), MakeNewAdaptedClass(), and MakeNewTempProtos().

00350                                  { 
00351   int Index;
00352   int ProtoSetId;
00353   PROTO_SET ProtoSet;
00354   INT_PROTO Proto;
00355   register UINT32 *Word;
00356 
00357   if (NumIntProtosIn (Class) >= MAX_NUM_PROTOS)
00358     return (NO_PROTO);
00359 
00360   Index = NumIntProtosIn (Class);
00361   NumIntProtosIn (Class)++;
00362 
00363   if (NumIntProtosIn (Class) > MaxNumIntProtosIn (Class)) {
00364     ProtoSetId = NumProtoSetsIn (Class);
00365     NumProtoSetsIn (Class)++;
00366 
00367     ProtoSet = (PROTO_SET) Emalloc (sizeof (PROTO_SET_STRUCT));
00368     ProtoSetIn (Class, ProtoSetId) = ProtoSet;
00369     for (Word = (UINT32 *) (ProtoPrunerFor (ProtoSet));
00370       Word < (UINT32 *) (ProtoPrunerFor (ProtoSet)) + WERDS_PER_PP;
00371       *Word++ = 0);
00372 
00373     /* reallocate space for the proto lengths and install in class */
00374     Class->ProtoLengths = (UINT8 *) Erealloc (Class->ProtoLengths,
00375       MaxNumIntProtosIn (Class) *
00376       sizeof (UINT8));
00377   }
00378 
00379   /* initialize proto so its length is zero and it isn't in any configs */
00380   LengthForProtoId (Class, Index) = 0;
00381   Proto = ProtoForProtoId (Class, Index);
00382   for (Word = Proto->Configs;
00383     Word < Proto->Configs + WERDS_PER_CONFIG_VEC; *Word++ = 0);
00384 
00385   return (Index);
00386 
00387 }                                /* AddIntProto */

void AddProtoToClassPruner ( PROTO  Proto,
CLASS_ID  ClassId,
INT_TEMPLATES  Templates 
)

Adds Proto to the class pruning tables for the specified class in Templates.

Parameters:
Proto Floating-pt proto to add to class pruner
ClassId Class id corresponding to Proto
Templates Set of templates containing class pruner
Note:
Globals: NumCPLevels Number of levels used in the class pruner
Returns:
none
Note:
Exceptions: none
Date:
Wed Feb 13 08:49:54 1991, DSJ, Created.

Definition at line 404 of file intproto.cpp.

References CPrunerFor, CPrunerMaskFor, CPrunerWordIndexFor, DoFill(), FillerDone(), GetCPPadsForLevel(), GetNextFill(), IndexForClassId, InitTableFiller(), and MAX_LEVEL.

Referenced by CreateIntTemplates(), and MakeTempProtoPerm().

00406 {
00407   CLASS_PRUNER Pruner;
00408   UINT32 ClassMask;
00409   UINT32 ClassCount;
00410   CLASS_INDEX ClassIndex;
00411   UINT32 WordIndex;
00412   int Level;
00413   FLOAT32 EndPad, SidePad, AnglePad;
00414   TABLE_FILLER TableFiller;
00415   FILL_SPEC FillSpec;
00416 
00417   ClassIndex = IndexForClassId (Templates, ClassId);
00418   Pruner = CPrunerFor (Templates, ClassIndex);
00419   WordIndex = CPrunerWordIndexFor (ClassIndex);
00420   ClassMask = CPrunerMaskFor (MAX_LEVEL, ClassIndex);
00421 
00422   for (Level = NumCPLevels - 1; Level >= 0; Level--) {
00423     GetCPPadsForLevel(Level, &EndPad, &SidePad, &AnglePad);
00424     ClassCount = CPrunerMaskFor (Level, ClassIndex);
00425     InitTableFiller(EndPad, SidePad, AnglePad, Proto, &TableFiller);
00426 
00427     while (!FillerDone (&TableFiller)) {
00428       GetNextFill(&TableFiller, &FillSpec);
00429       DoFill(&FillSpec, Pruner, ClassMask, ClassCount, WordIndex);
00430     }
00431   }
00432 }                                /* AddProtoToClassPruner */

void AddProtoToProtoPruner ( PROTO  Proto,
int  ProtoId,
INT_CLASS  Class 
)

Updates the proto-pruner lookup tables for Class to include a new proto identified by ProtoId and described by Proto.

Parameters:
Proto Floating-pt proto to be added to proto pruner
ProtoId Id of proto
Class Integer class that contains desired proto pruner
Returns:
none
Note:
Exceptions: none
Date:
Fri Feb 8 13:07:19 1991, DSJ, Created.

Definition at line 447 of file intproto.cpp.

References ANGLE_SHIFT, assert(), cprintf(), FillPPCircularBits(), FillPPLinearBits(), GetPicoFeatureLength, IndexForProto, max, NumIntProtosIn, PI, ProtoAngle, ProtoLength, ProtoSetIn, ProtoX, ProtoY, PRUNER_ANGLE, PRUNER_X, PRUNER_Y, SetForProto, X_SHIFT, and Y_SHIFT.

Referenced by CreateIntTemplates(), MakeNewAdaptedClass(), and MakeNewTempProtos().

00447                                                                       { 
00448   FLOAT32 Angle, X, Y, Length;
00449   FLOAT32 Pad;
00450   int Index;
00451   PROTO_SET ProtoSet;
00452 
00453   if (ProtoId >= NumIntProtosIn (Class))
00454     cprintf ("AddProtoToProtoPruner:assert failed: %d < %d",
00455       ProtoId, NumIntProtosIn (Class));
00456   assert (ProtoId < NumIntProtosIn (Class));
00457 
00458   Index = IndexForProto (ProtoId);
00459   ProtoSet = ProtoSetIn (Class, SetForProto (ProtoId));
00460 
00461   Angle = ProtoAngle (Proto);
00462   FillPPCircularBits (ProtoSet->ProtoPruner[PRUNER_ANGLE], Index,
00463     Angle + ANGLE_SHIFT, PPAnglePad / 360.0);
00464 
00465   Angle *= 2.0 * PI;
00466   Length = ProtoLength (Proto);
00467 
00468   X = ProtoX (Proto) + X_SHIFT;
00469   Pad = max (fabs (cos (Angle)) * (Length / 2.0 +
00470     PPEndPad * GetPicoFeatureLength ()),
00471     fabs (sin (Angle)) * (PPSidePad * GetPicoFeatureLength ()));
00472 
00473   FillPPLinearBits (ProtoSet->ProtoPruner[PRUNER_X], Index, X, Pad);
00474 
00475   Y = ProtoY (Proto) + Y_SHIFT;
00476   Pad = max (fabs (sin (Angle)) * (Length / 2.0 +
00477     PPEndPad * GetPicoFeatureLength ()),
00478     fabs (cos (Angle)) * (PPSidePad * GetPicoFeatureLength ()));
00479 
00480   FillPPLinearBits (ProtoSet->ProtoPruner[PRUNER_Y], Index, Y, Pad);
00481 
00482 }                                /* AddProtoToProtoPruner */

int BucketFor ( FLOAT32  Param,
FLOAT32  Offset,
int  NumBuckets 
)

Maps a parameter value into a bucket between 0 and NumBuckets-1.

Parameters:
Param Parameter value to map into a bucket number
Offset Amount to shift param before mapping it
NumBuckets Number of buckets to map param into
Returns:
Bucket number corresponding to Param + Offset.
Offset is added to the parameter before mapping it. Values which map to buckets outside the range are truncated to fit within the range. Mapping is done by truncating rather than rounding.
Note:
Exceptions: none
Date:
Thu Feb 14 13:24:33 1991, DSJ, Created.

Definition at line 501 of file intproto.cpp.

References MapParam.

Referenced by ComputeIntFeatures(), and InitTableFiller().

00501                                                              { 
00502   int Bucket;
00503 
00504   Bucket = (int) MapParam (Param, Offset, NumBuckets);
00505   if (Bucket < 0)
00506     Bucket = 0;
00507   else if (Bucket >= NumBuckets)
00508     Bucket = NumBuckets - 1;
00509   return (Bucket);
00510 
00511 }                                /* BucketFor */

int CircBucketFor ( FLOAT32  Param,
FLOAT32  Offset,
int  NumBuckets 
)

Maps a parameter value into a bucket between 0 and NumBuckets-1.

Parameters:
Param Parameter value to map into a circular bucket
Offset Amount to shift param before mapping it
NumBuckets Number of buckets to map param into
Returns:
Bucket number corresponding to Param + Offset.
Offset is added to the parameter before mapping it. Values which map to buckets outside the range are wrapped to a new value in a circular fashion. Mapping is done by truncating rather than rounding.
Note:
Exceptions: none
Date:
Thu Feb 14 13:24:33 1991, DSJ, Created.

Definition at line 529 of file intproto.cpp.

References MapParam.

Referenced by ComputeIntFeatures(), and InitTableFiller().

00529                                                                  { 
00530   int Bucket;
00531 
00532   Bucket = (int) MapParam (Param, Offset, NumBuckets);
00533   if (Bucket < 0)
00534     Bucket += NumBuckets;
00535   else if (Bucket >= NumBuckets)
00536     Bucket -= NumBuckets;
00537   return (Bucket);
00538 
00539 }                                /* CircBucketFor */

void ConvertConfig ( BIT_VECTOR  Config,
int  ConfigId,
INT_CLASS  Class 
)

Update config vectors of all protos in Class.

Parameters:
Config Config to be added to class
ConfigId Id to be used for new config
Class Class to add new config to
Returns:
none
Indicate that the protos with 1's in Config belong to a new configuration identified by ConfigId.

It is assumed that the length of the Config bit vector is equal to the number of protos in Class.

Note:
Exceptions: none
Date:
Mon Feb 11 14:57:31 1991, DSJ, Created.

Definition at line 578 of file intproto.cpp.

References LengthForConfigId, LengthForProtoId, NumIntProtosIn, ProtoForProtoId, SET_BIT, and test_bit.

Referenced by CreateIntTemplates(), MakeNewAdaptedClass(), and MakeNewTemporaryConfig().

00578                                                                      { 
00579   int ProtoId;
00580   INT_PROTO Proto;
00581   int TotalLength;
00582 
00583   for (ProtoId = 0, TotalLength = 0;
00584     ProtoId < NumIntProtosIn (Class); ProtoId++)
00585   if (test_bit (Config, ProtoId)) {
00586     Proto = ProtoForProtoId (Class, ProtoId);
00587     SET_BIT (Proto->Configs, ConfigId);
00588     TotalLength += LengthForProtoId (Class, ProtoId);
00589   }
00590   LengthForConfigId (Class, ConfigId) = TotalLength;
00591 }                                /* ConvertConfig */

void ConvertProto ( PROTO  Proto,
int  ProtoId,
INT_CLASS  Class 
)

Converts Proto to integer format and installs it as ProtoId in Class.

Parameters:
Proto Floating-pt proto to be converted to integer format
ProtoId Id of proto
Class Integer class to add converted proto to
Returns:
none
Note:
Exceptions: none
Date:
Fri Feb 8 11:22:43 1991, DSJ, Created.

Definition at line 605 of file intproto.cpp.

References assert(), CoefficientA, CoefficientB, CoefficientC, cprintf(), GetPicoFeatureLength, LearningDebugLevel, LengthForProtoId, NULL, NumIntProtosIn, ProtoAngle, ProtoForProtoId, ProtoLength, and TruncateParam().

Referenced by CreateIntTemplates(), MakeNewAdaptedClass(), and MakeNewTempProtos().

00605                                                              { 
00606   INT_PROTO P;
00607   FLOAT32 Param;
00608 
00609   assert (ProtoId < NumIntProtosIn (Class));
00610 
00611   P = ProtoForProtoId (Class, ProtoId);
00612 
00613   Param = CoefficientA (Proto) * 128;
00614   P->A = TruncateParam (Param, -128, 127, NULL);
00615 
00616   Param = -CoefficientB (Proto) * 256;
00617   P->B = TruncateParam (Param, 0, 255, NULL);
00618 
00619   Param = CoefficientC (Proto) * 128;
00620   P->C = TruncateParam (Param, -128, 127, NULL);
00621 
00622   Param = ProtoAngle (Proto) * 256;
00623   if (Param < 0 || Param >= 256)
00624     P->Angle = 0;
00625   else
00626     P->Angle = (UINT8) Param;
00627 
00628   /* round proto length to nearest integer number of pico-features */
00629   Param = (ProtoLength (Proto) / GetPicoFeatureLength ()) + 0.5;
00630   LengthForProtoId (Class, ProtoId) = TruncateParam (Param, 1, 255, NULL);
00631   if (LearningDebugLevel >= 2)
00632     cprintf ("Converted ffeat to (A=%d,B=%d,C=%d,L=%d)",
00633       P->A, P->B, P->C, LengthForProtoId (Class, ProtoId));
00634 }                                /* ConvertProto */

INT_TEMPLATES CreateIntTemplates ( CLASSES  FloatProtos  ) 

Converts from the old floating point format to the new integer format.

Parameters:
FloatProtos Prototypes in old floating pt format
Returns:
New set of training templates in integer format.
Note:
Exceptions: none
Date:
Thu Feb 7 14:40:42 1991, DSJ, Created.

Definition at line 646 of file intproto.cpp.

References AddIntClass(), AddIntConfig(), AddIntProto(), AddProtoToClassPruner(), AddProtoToProtoPruner(), assert(), ConfigIn, ConvertConfig(), ConvertProto(), NewIntClass(), NewIntTemplates(), NUMBER_OF_CLASSES, NumConfigsIn, NumProtosIn, ProtoIn, and UnusedClassIdIn.

00646                                                       { 
00647   INT_TEMPLATES IntTemplates;
00648   CLASS_TYPE FClass;
00649   INT_CLASS IClass;
00650   int ClassId;
00651   int ProtoId;
00652   int ConfigId;
00653 
00654   IntTemplates = NewIntTemplates ();
00655 
00656   for (ClassId = 0; ClassId < NUMBER_OF_CLASSES; ClassId++) {
00657     FClass = &(FloatProtos[ClassId]);
00658     if (NumProtosIn (FClass) > 0) {
00659       assert (UnusedClassIdIn (IntTemplates, ClassId));
00660 
00661       IClass = NewIntClass (NumProtosIn (FClass), NumConfigsIn (FClass));
00662       AddIntClass(IntTemplates, ClassId, IClass);
00663 
00664       for (ProtoId = 0; ProtoId < NumProtosIn (FClass); ProtoId++) {
00665         AddIntProto(IClass);
00666         ConvertProto (ProtoIn (FClass, ProtoId), ProtoId, IClass);
00667         AddProtoToProtoPruner (ProtoIn (FClass, ProtoId), ProtoId,
00668           IClass);
00669         AddProtoToClassPruner (ProtoIn (FClass, ProtoId), ClassId,
00670           IntTemplates);
00671       }
00672 
00673       for (ConfigId = 0; ConfigId < NumConfigsIn (FClass); ConfigId++) {
00674         AddIntConfig(IClass);
00675         ConvertConfig (ConfigIn (FClass, ConfigId), ConfigId, IClass);
00676       }
00677     }
00678   }
00679   return (IntTemplates);
00680 }                                /* CreateIntTemplates */

void DisplayIntFeature ( INT_FEATURE  Feature,
FLOAT32  Evidence 
)

Renders the specified feature into a global display list.

Parameters:
Feature Pico-feature to be displayed
Evidence Best evidence for this feature (0-1)
Note:
Globals: FeatureShapes Global display list for features
Returns:
none
Note:
Exceptions: none
Date:
Thu Mar 21 14:45:04 1991, DSJ, Created.

Definition at line 695 of file intproto.cpp.

References GetMatchColorFor(), IntMatchWindow, and RenderIntFeature().

Referenced by IMDisplayFeatureDebugInfo().

00695                                                               { 
00696   C_COL Color;
00697 
00698   Color = GetMatchColorFor (Evidence);
00699   RenderIntFeature(IntMatchWindow, Feature, Color);
00700 }                                /* DisplayIntFeature */

void DisplayIntProto ( INT_CLASS  Class,
PROTO_ID  ProtoId,
FLOAT32  Evidence 
)

Renders the specified proto into a global display list.

Parameters:
Class Class to take proto from
ProtoId Id of proto in Class to be displayed
Evidence Total evidence for proto (0-1)
Note:
Globals: ProtoShapes Global display list for protos
Returns:
none
Note:
Exceptions: none
Date:
Thu Mar 21 14:45:04 1991, DSJ, Created.

Definition at line 715 of file intproto.cpp.

References GetMatchColorFor(), IntMatchWindow, and RenderIntProto().

Referenced by IMDisplayProtoDebugInfo().

00715                                                                           { 
00716   C_COL Color;
00717 
00718   Color = GetMatchColorFor (Evidence);
00719   RenderIntProto(IntMatchWindow, Class, ProtoId, Color);
00720 
00721 }                                /* DisplayIntProto */

void free_int_class ( INT_CLASS  int_class  ) 

Frees a class.

Definition at line 802 of file intproto.cpp.

References Efree(), NumProtoSetsIn, and ProtoSetIn.

Referenced by free_int_templates().

00803                                          {  /*class to free */
00804   int i;
00805 
00806   for (i = 0; i < NumProtoSetsIn (int_class); i++) {
00807     Efree (ProtoSetIn (int_class, i));
00808   }
00809   Efree (int_class->ProtoLengths);
00810   Efree(int_class);
00811 }

void free_int_templates ( INT_TEMPLATES  templates  ) 

Frees the template.

Definition at line 846 of file intproto.cpp.

References ClassForIndex, Efree(), free_int_class(), NumClassesIn, and NumClassPrunersIn.

Referenced by EndAdaptiveClassifier(), and free_adapted_templates().

00846                                                  { 
00847   int i;
00848 
00849   for (i = 0; i < NumClassesIn (templates); i++)
00850     free_int_class (ClassForIndex (templates, i));
00851   for (i = 0; i < NumClassPrunersIn (templates); i++)
00852     Efree (templates->ClassPruner[i]);
00853   Efree(templates);
00854 }

CLASS_ID GetClassToDebug ( const char *  Prompt  ) 

void InitIntProtoVars (  ) 

Initialize the control variables for the integer proto routines.

Parameters:
none 
Returns:
none
Note:
Exceptions: none
Date:
Tue Feb 12 08:04:34 1991, DSJ, Created.

Definition at line 733 of file intproto.cpp.

Referenced by init_dj_debug().

00733                         { 
00734   MakeNumCPLevels();
00735   MakeCPAnglePadLoose();
00736   MakeCPAnglePadMedium();
00737   MakeCPAnglePadTight();
00738   MakeCPEndPadLoose();
00739   MakeCPEndPadMedium();
00740   MakeCPEndPadTight();
00741   MakeCPSidePadLoose();
00742   MakeCPSidePadMedium();
00743   MakeCPSidePadTight();
00744   MakePPAnglePad();
00745   MakePPEndPad();
00746   MakePPSidePad();
00747 }                                /* InitIntProtoVars */

INT_CLASS NewIntClass ( int  MaxNumProtos,
int  MaxNumConfigs 
)

Creates a new integer class data structure and returns it.

Parameters:
MaxNumProtos Number of protos to allocate space for
MaxNumConfigs Number of configs to allocate space for
Returns:
New class created.
Sufficient space is allocated to handle the specified number of protos and configs.
Note:
Exceptions: none
Date:
Fri Feb 8 10:51:23 1991, DSJ, Created.

Definition at line 763 of file intproto.cpp.

References assert(), Emalloc(), MAX_NUM_CONFIGS, MAX_NUM_PROTO_SETS, MaxNumIntProtosIn, NumIntConfigsIn, NumIntProtosIn, NumProtoSetsIn, ProtoPrunerFor, PROTOS_PER_PROTO_SET, ProtoSetIn, and WERDS_PER_PP.

Referenced by AddAdaptedClass(), and CreateIntTemplates().

00763                                                            { 
00764   INT_CLASS Class;
00765   PROTO_SET ProtoSet;
00766   int i;
00767   register UINT32 *Word;
00768 
00769   assert (MaxNumConfigs <= MAX_NUM_CONFIGS);
00770 
00771   Class = (INT_CLASS) Emalloc (sizeof (INT_CLASS_STRUCT));
00772   NumProtoSetsIn (Class) = ((MaxNumProtos + PROTOS_PER_PROTO_SET - 1) /
00773     PROTOS_PER_PROTO_SET);
00774 
00775   assert (NumProtoSetsIn (Class) <= MAX_NUM_PROTO_SETS);
00776 
00777   NumIntProtosIn (Class) = 0;
00778   NumIntConfigsIn (Class) = 0;
00779 
00780   for (i = 0; i < NumProtoSetsIn (Class); i++) {
00781     /* allocate space for a proto set, install in class, and initialize */
00782     ProtoSet = (PROTO_SET) Emalloc (sizeof (PROTO_SET_STRUCT));
00783     ProtoSetIn (Class, i) = ProtoSet;
00784     for (Word = (UINT32 *) (ProtoPrunerFor (ProtoSet));
00785       Word < (UINT32 *) (ProtoPrunerFor (ProtoSet)) + WERDS_PER_PP;
00786       *Word++ = 0);
00787 
00788     /* allocate space for the proto lengths and install in class */
00789   }
00790   Class->ProtoLengths = (UINT8 *) Emalloc (MaxNumIntProtosIn (Class) *
00791     sizeof (UINT8));
00792 
00793   return (Class);
00794 
00795 }                                /* NewIntClass */

INT_TEMPLATES NewIntTemplates (  ) 

Allocates a new set of integer templates initialized to hold 0 classes.

Parameters:
none 
Returns:
The integer templates created.
Note:
Exceptions: none
Date:
Fri Feb 8 08:38:51 1991, DSJ, Created.

Definition at line 823 of file intproto.cpp.

References ClassIdForIndex, Emalloc(), ILLEGAL_CLASS, IndexForClassId, MAX_CLASS_ID, MAX_NUM_CLASSES, NO_CLASS, NumClassesIn, and NumClassPrunersIn.

Referenced by CreateIntTemplates(), NewAdaptedTemplates(), and ReadIntTemplates().

00823                                 { 
00824   INT_TEMPLATES T;
00825   int i;
00826 
00827   T = (INT_TEMPLATES) Emalloc (sizeof (INT_TEMPLATES_STRUCT));
00828   NumClassesIn (T) = 0;
00829   NumClassPrunersIn (T) = 0;
00830 
00831   /* initialize mapping tables */
00832   for (i = 0; i <= MAX_CLASS_ID; i++)
00833     IndexForClassId (T, i) = ILLEGAL_CLASS;
00834   for (i = 0; i < MAX_NUM_CLASSES; i++)
00835     ClassIdForIndex (T, i) = NO_CLASS;
00836 
00837   return (T);
00838 
00839 }                                /* NewIntTemplates */

INT_TEMPLATES ReadIntTemplates ( FILE *  File,
BOOL8  swap 
)

Reads a set of integer templates from File.

Parameters:
File Open file to read templates from
swap 0 or 1, if need to call reverse32
Returns:
Pointer to integer templates read from File.
File must already be open and must be in the correct binary format.
Note:
Exceptions: none
Date:
Wed Feb 27 11:48:46 1991, DSJ, Created.

Definition at line 870 of file intproto.cpp.

References ClassForIndex, cprintf(), Emalloc(), MAX_CLASS_ID, MAX_NUM_CLASS_PRUNERS, MAX_NUM_CLASSES, MAX_NUM_CONFIGS, MAX_NUM_PROTO_SETS, MaxNumIntProtosIn, NewIntTemplates(), NUM_CP_BUCKETS, NUM_PP_BUCKETS, NUM_PP_PARAMS, NumClassesIn, NumClassPrunersIn, NumProtoSetsIn, PROTOS_PER_PROTO_SET, ProtoSetIn, reverse16(), reverse32(), WERDS_PER_CONFIG_VEC, WERDS_PER_CP_VECTOR, and WERDS_PER_PP_VECTOR.

Referenced by InitAdaptiveClassifier(), and ReadAdaptedTemplates().

00870                                                        { 
00871   int i, j, x, y, z;
00872   int nread;
00873   INT_TEMPLATES Templates;
00874   CLASS_PRUNER Pruner;
00875   INT_CLASS Class;
00876   UINT8 *Lengths;
00877   PROTO_SET ProtoSet;
00878 
00879   /* first read the high level template struct */
00880   Templates = NewIntTemplates ();
00881   // Read Templates in parts for 64 bit compatibility.
00882   if (fread(&Templates->NumClasses, sizeof(int), 1, File) != 1 ||
00883       fread(&Templates->NumClassPruners, sizeof(int), 1, File) != 1)
00884     cprintf ("Bad read of inttemp!\n");
00885   for (i = 0; i <= MAX_CLASS_ID; ++i) {
00886     if (fread(&Templates->IndexFor[i], sizeof(CLASS_INDEX), 1, File) != 1)
00887       cprintf("Bad read of inttemp!\n");
00888   }
00889   for (i = 0; i < MAX_NUM_CLASSES; ++i) {
00890     if (fread(&Templates->ClassIdFor[i], sizeof(CLASS_ID), 1, File) != 1)
00891       cprintf("Bad read of inttemp!\n");
00892   }
00893   for (i = 0; i < MAX_NUM_CLASSES + MAX_NUM_CLASS_PRUNERS; ++i) {
00894     int junk;
00895     if (fread(&junk, sizeof(junk), 1, File) != 1)
00896       cprintf("Bad read of inttemp!\n");
00897   }
00898   // Swap status is determined automatically.
00899   swap = Templates->NumClassPruners < 0 ||
00900          Templates->NumClassPruners > MAX_NUM_CLASS_PRUNERS;
00901   if (swap) {
00902     reverse32 (&Templates->NumClassPruners);
00903     reverse32 (&Templates->NumClasses);
00904     for (i = 0; i < MAX_CLASS_ID + 1; i++)
00905       reverse16 (&Templates->IndexFor[i]);
00906   }
00907 
00908   /* then read in the class pruners */
00909   for (i = 0; i < NumClassPrunersIn (Templates); i++) {
00910     Pruner = (CLASS_PRUNER) Emalloc (sizeof (CLASS_PRUNER_STRUCT));
00911     if ((nread =
00912       fread ((char *) Pruner, 1, sizeof (CLASS_PRUNER_STRUCT),
00913       File)) != sizeof (CLASS_PRUNER_STRUCT))
00914       cprintf ("Bad read of inttemp!\n");
00915     if (swap) {
00916       for (j = 0; j < NUM_CP_BUCKETS; j++) {
00917         for (x = 0; x < NUM_CP_BUCKETS; x++) {
00918           for (y = 0; y < NUM_CP_BUCKETS; y++) {
00919             for (z = 0; z < WERDS_PER_CP_VECTOR; z++) {
00920               reverse32 (&Pruner[j][x][y][z]);
00921             }
00922           }
00923         }
00924       }
00925     }
00926     Templates->ClassPruner[i] = Pruner;
00927   }
00928 
00929   /* then read in each class */
00930   for (i = 0; i < NumClassesIn (Templates); i++) {
00931     /* first read in the high level struct for the class */
00932     Class = (INT_CLASS) Emalloc (sizeof (INT_CLASS_STRUCT));
00933     if (fread(&Class->NumProtos, sizeof(Class->NumProtos), 1, File) != 1 ||
00934         fread(&Class->NumProtoSets, sizeof(Class->NumProtoSets), 1, File) != 1 ||
00935         fread(&Class->NumConfigs, sizeof(Class->NumConfigs), 1, File) != 1)
00936       cprintf ("Bad read of inttemp!\n");
00937     for (j = 0; j <= MAX_NUM_PROTO_SETS; ++j) {
00938       int junk;
00939       if (fread(&junk, sizeof(junk), 1, File) != 1)
00940         cprintf ("Bad read of inttemp!\n");
00941     }
00942     for (j = 0; j < MAX_NUM_CONFIGS; ++j) {
00943       if (fread(&Class->ConfigLengths[j], sizeof(UINT16), 1, File) != 1)
00944         cprintf ("Bad read of inttemp!\n");
00945     }
00946     if (swap) {
00947       reverse16 (&Class->NumProtos);
00948       for (j = 0; j < MAX_NUM_CONFIGS; j++)
00949         reverse16 (&Class->ConfigLengths[j]);
00950     }
00951     ClassForIndex (Templates, i) = Class;
00952 
00953     /* then read in the proto lengths */
00954     Lengths = (UINT8 *) Emalloc (sizeof (UINT8) *
00955       MaxNumIntProtosIn (Class));
00956     if ((nread = fread ((char *) Lengths, sizeof (UINT8),
00957       MaxNumIntProtosIn (Class),
00958       File)) != MaxNumIntProtosIn (Class))
00959       cprintf ("Bad read of inttemp!\n");
00960     Class->ProtoLengths = Lengths;
00961 
00962     /* then read in the proto sets */
00963     for (j = 0; j < NumProtoSetsIn (Class); j++) {
00964       ProtoSet = (PROTO_SET) Emalloc (sizeof (PROTO_SET_STRUCT));
00965       if ((nread =
00966         fread ((char *) ProtoSet, 1, sizeof (PROTO_SET_STRUCT),
00967         File)) != sizeof (PROTO_SET_STRUCT))
00968         cprintf ("Bad read of inttemp!\n");
00969       if (swap) {
00970         for (x = 0; x < NUM_PP_PARAMS; x++)
00971           for (y = 0; y < NUM_PP_BUCKETS; y++)
00972             for (z = 0; z < WERDS_PER_PP_VECTOR; z++)
00973               reverse32 (&ProtoSet->ProtoPruner[x][y][z]);
00974         for (x = 0; x < PROTOS_PER_PROTO_SET; x++)
00975           for (y = 0; y < WERDS_PER_CONFIG_VEC; y++)
00976             reverse32 (&ProtoSet->Protos[x].Configs[y]);
00977       }
00978       ProtoSetIn (Class, j) = ProtoSet;
00979     }
00980   }
00981   return (Templates);
00982 }                                /* ReadIntTemplates */

void ShowMatchDisplay (  ) 

Sends the shapes in the global display lists to the match debugger window.

Parameters:
none 
Note:
Globals:
  • FeatureShapes Display list containing feature matches
  • ProtoShapes Display list containing proto matches
Returns:
none
Note:
Exceptions: none
Date:
Thu Mar 21 15:47:33 1991, DSJ, Created.

Definition at line 999 of file intproto.cpp.

References baseline, c_clear_window(), c_create_window(), c_draw(), c_line_color_index(), c_move(), Grey, INT_BASELINE, INT_CAPHEIGHT, INT_DESCENDER, INT_MAX_X, INT_MAX_Y, INT_MIN_X, INT_MIN_Y, INT_XCENTER, INT_XHEIGHT, INT_XRADIUS, INT_YCENTER, INT_YRADIUS, IntMatchWindow, NormMethod, and NULL.

Referenced by AdaptToChar(), and DebugAdaptiveClassifier().

00999                         { 
01000   void *window;
01001   /* Size of drawable */
01002   if (IntMatchWindow == NULL) {
01003     IntMatchWindow = c_create_window ("IntMatchWindow", 50, 200,
01004       520, 520,
01005       -130.0, 130.0, -130.0, 130.0);
01006   }
01007   else
01008     c_clear_window(IntMatchWindow);
01009 
01010   window = IntMatchWindow;
01011   c_line_color_index(window, Grey);
01012   /* Default size of drawing */
01013   if (NormMethod == baseline) {
01014     c_move (window, -1000.0, INT_BASELINE);
01015     c_draw (window, 1000.0, INT_BASELINE);
01016     c_move (window, -1000.0, INT_DESCENDER);
01017     c_draw (window, 1000.0, INT_DESCENDER);
01018     c_move (window, -1000.0, INT_XHEIGHT);
01019     c_draw (window, 1000.0, INT_XHEIGHT);
01020     c_move (window, -1000.0, INT_CAPHEIGHT);
01021     c_draw (window, 1000.0, INT_CAPHEIGHT);
01022     c_move (window, INT_MIN_X, -1000.0);
01023     c_draw (window, INT_MIN_X, 1000.0);
01024     c_move (window, INT_MAX_X, -1000.0);
01025     c_draw (window, INT_MAX_X, 1000.0);
01026   }
01027   else {
01028     c_move (window, INT_XCENTER - INT_XRADIUS, INT_YCENTER - INT_YRADIUS);
01029     c_draw (window, INT_XCENTER + INT_XRADIUS, INT_YCENTER - INT_YRADIUS);
01030     c_move (window, INT_XCENTER - INT_XRADIUS, INT_YCENTER + INT_YRADIUS);
01031     c_draw (window, INT_XCENTER + INT_XRADIUS, INT_YCENTER + INT_YRADIUS);
01032     c_move (window, INT_XCENTER - INT_XRADIUS, INT_YCENTER - INT_YRADIUS);
01033     c_draw (window, INT_XCENTER - INT_XRADIUS, INT_YCENTER + INT_YRADIUS);
01034     c_move (window, INT_XCENTER + INT_XRADIUS, INT_YCENTER - INT_YRADIUS);
01035     c_draw (window, INT_XCENTER + INT_XRADIUS, INT_YCENTER + INT_YRADIUS);
01036     c_move(window, INT_MIN_X, INT_MIN_Y);
01037     c_draw(window, INT_MIN_X, INT_MAX_Y);
01038     c_move(window, INT_MIN_X, INT_MIN_Y);
01039     c_draw(window, INT_MAX_X, INT_MIN_Y);
01040     c_move(window, INT_MAX_X, INT_MAX_Y);
01041     c_draw(window, INT_MIN_X, INT_MAX_Y);
01042     c_move(window, INT_MAX_X, INT_MAX_Y);
01043     c_draw(window, INT_MAX_X, INT_MIN_Y);
01044   }
01045 }                                /* ShowMatchDisplay */

void UpdateMatchDisplay (  ) 

Clears the global feature and proto display lists.

Parameters:
none 
Note:
Globals:
  • FeatureShapes Display list for features
  • GProtoShapes Display list for protos
Returns:
none
Note:
Exceptions: none
Date:
Thu Mar 21 15:40:19 1991, DSJ, Created.

Definition at line 555 of file intproto.cpp.

References c_make_current(), IntMatchWindow, and NULL.

Referenced by AdaptToChar(), and DebugAdaptiveClassifier().

00555                           { 
00556   if (IntMatchWindow != NULL)
00557     c_make_current(IntMatchWindow);
00558 }                                /* ClearMatchDisplay */

void WriteIntTemplates ( FILE *  File,
INT_TEMPLATES  Templates 
)

Writes Templates to File.

Parameters:
File Open file to write templates to
Templates Templates to save into File
Returns:
none
The format is an efficient binary format. File must already be open for writing.
Note:
Exceptions: none
Date:
Wed Feb 27 11:48:46 1991, DSJ, Created.

Definition at line 1061 of file intproto.cpp.

References ClassForIndex, MaxNumIntProtosIn, NumClassesIn, NumClassPrunersIn, NumProtoSetsIn, and ProtoSetIn.

Referenced by WriteAdaptedTemplates().

01061                                                             { 
01062   int i, j;
01063   INT_CLASS Class;
01064 
01065   /* first write the high level template struct */
01066   fwrite ((char *) Templates, sizeof (INT_TEMPLATES_STRUCT), 1, File);
01067 
01068   /* then write out the class pruners */
01069   for (i = 0; i < NumClassPrunersIn (Templates); i++)
01070     fwrite ((char *) (Templates->ClassPruner[i]),
01071       sizeof (CLASS_PRUNER_STRUCT), 1, File);
01072 
01073   /* then write out each class */
01074   for (i = 0; i < NumClassesIn (Templates); i++) {
01075     Class = ClassForIndex (Templates, i);
01076 
01077     /* first write out the high level struct for the class */
01078     fwrite ((char *) Class, sizeof (INT_CLASS_STRUCT), 1, File);
01079 
01080     /* then write out the proto lengths */
01081     fwrite ((char *) (Class->ProtoLengths), sizeof (UINT8),
01082       MaxNumIntProtosIn (Class), File);
01083 
01084     /* then write out the proto sets */
01085     for (j = 0; j < NumProtoSetsIn (Class); j++)
01086       fwrite ((char *) ProtoSetIn (Class, j),
01087         sizeof (PROTO_SET_STRUCT), 1, File);
01088   }
01089 }                                /* WriteIntTemplates */


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