classify/intproto.cpp File Reference

#include "intproto.h"
#include "picofeat.h"
#include "debug.h"
#include "mfoutline.h"
#include "emalloc.h"
#include "const.h"
#include "ndminx.h"
#include "adaptmatch.h"
#include <math.h>
#include <stdio.h>
#include <assert.h>

Go to the source code of this file.

Classes

Defines

Enumerations

Functions

Variables


Define Documentation

#define AS   ANGLE_SHIFT

Referenced by InitTableFiller().

#define CircularIncrement ( i,
 )     (((i) < (r) - 1)?((i)++):((i) = 0))

Performing circular increments of bucket indices

Definition at line 114 of file intproto.cpp.

Referenced by DoFill(), and FillPPCircularBits().

#define DISPLAY_OFFSET   (0.5 * INT_CHAR_NORM_RANGE)

Note:
File: intproto.cpp
Definition of data structures for integer protos.
Author:
Dan Johnson
Date:
Thu Feb 7 14:38:16 1991, 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 38 of file intproto.cpp.

Referenced by RenderIntFeature(), and RenderIntProto().

#define DOUBLE_OFFSET   0.095

Definition at line 54 of file intproto.cpp.

Referenced by RenderIntFeature().

#define HV_TOLERANCE   (0.0025)

Pad used to snap near horiz/vertical protos to horiz/vertical; approx 0.9 degrees

Definition at line 58 of file intproto.cpp.

Referenced by InitTableFiller().

#define INT_BASELINE   (0.25 * INT_CHAR_NORM_RANGE - DISPLAY_OFFSET)

Definition at line 42 of file intproto.cpp.

Referenced by ShowMatchDisplay().

#define INT_CAPHEIGHT   (1.0 * INT_CHAR_NORM_RANGE - DISPLAY_OFFSET)

Definition at line 44 of file intproto.cpp.

Referenced by ShowMatchDisplay().

#define INT_DESCENDER   (0.0 * INT_CHAR_NORM_RANGE - DISPLAY_OFFSET)

Definition at line 41 of file intproto.cpp.

Referenced by ShowMatchDisplay().

#define INT_MAX_X   ( DISPLAY_OFFSET)

Definition at line 52 of file intproto.cpp.

Referenced by ShowMatchDisplay().

#define INT_MAX_Y   ( DISPLAY_OFFSET)

Definition at line 53 of file intproto.cpp.

Referenced by ShowMatchDisplay().

#define INT_MIN_X   (- DISPLAY_OFFSET)

Definition at line 50 of file intproto.cpp.

Referenced by ShowMatchDisplay().

#define INT_MIN_Y   (- DISPLAY_OFFSET)

Definition at line 51 of file intproto.cpp.

Referenced by ShowMatchDisplay().

#define INT_XCENTER   (0.5 * INT_CHAR_NORM_RANGE - DISPLAY_OFFSET)

Definition at line 46 of file intproto.cpp.

Referenced by ShowMatchDisplay().

#define INT_XHEIGHT   (0.75 * INT_CHAR_NORM_RANGE - DISPLAY_OFFSET)

Definition at line 43 of file intproto.cpp.

Referenced by ShowMatchDisplay().

#define INT_XRADIUS   (0.2 * INT_CHAR_NORM_RANGE)

Definition at line 48 of file intproto.cpp.

Referenced by ShowMatchDisplay().

#define INT_YCENTER   (0.5 * INT_CHAR_NORM_RANGE - DISPLAY_OFFSET)

Definition at line 47 of file intproto.cpp.

Referenced by ShowMatchDisplay().

#define INT_YRADIUS   (0.2 * INT_CHAR_NORM_RANGE)

Definition at line 49 of file intproto.cpp.

Referenced by ShowMatchDisplay().

#define MapParam ( P,
O,
N   )     (floor (((P) + (O)) * (N)))

Mapping floats to ints without bounds checking

Definition at line 117 of file intproto.cpp.

Referenced by BucketFor(), CircBucketFor(), and InitTableFiller().

#define MAX_LEVEL   2

Referenced by AddProtoToClassPruner().

#define MAX_NUM_SWITCHES   3

Definition at line 71 of file intproto.cpp.

#define NB   NUM_CP_BUCKETS

Referenced by InitTableFiller().

#define PROTO_PRUNER_SCALE   (4.0)

Definition at line 39 of file intproto.cpp.

Referenced by RenderIntProto().

#define XS   X_SHIFT

Referenced by InitTableFiller().

#define YS   Y_SHIFT

Referenced by InitTableFiller().


Enumeration Type Documentation

enum SWITCH_TYPE

FIX: something for integer prototypes.

Enumerator:
StartSwitch 
EndSwitch 
LastSwitch 

Definition at line 64 of file intproto.cpp.

00065 {
00066    StartSwitch,
00067    EndSwitch,
00068    LastSwitch
00069 } SWITCH_TYPE;


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 */

FLOAT32 BucketEnd ( int  Bucket,
FLOAT32  Offset,
int  NumBuckets 
)

Returns the parameter value which corresponds to the end of the specified bucket.

Parameters:
Bucket Bucket whose end is to be computed
Offset Offset used to map params to buckets
NumBuckets Total number of buckets
Returns:
Param value corresponding to end position of Bucket.
The bucket number should have been generated using the BucketFor() function with parameters Offset and NumBuckets.
Note:
Exceptions: none
Date:
Thu Feb 14 13:24:33 1991, DSJ, Created.

Definition at line 1131 of file intproto.cpp.

Referenced by InitTableFiller().

01131                                                               { 
01132   return (((FLOAT32) (Bucket + 1) / NumBuckets) - Offset);
01133 }                                /* BucketEnd */

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 */

FLOAT32 BucketStart ( int  Bucket,
FLOAT32  Offset,
int  NumBuckets 
)

Returns the parameter value which corresponds to the beginning of the specified bucket.

Parameters:
Bucket Bucket whose start is to be computed
Offset Offset used to map params to buckets
NumBuckets Total number of buckets
Returns:
Param Value corresponding to start position of Bucket.
The bucket number should have been generated using the BucketFor() function with parameters Offset and NumBuckets.
Note:
Exceptions: none
Date:
Thu Feb 14 13:24:33 1991, DSJ, Created.

Definition at line 1110 of file intproto.cpp.

Referenced by InitTableFiller().

01110                                                                 { 
01111   return (((FLOAT32) Bucket / NumBuckets) - Offset);
01112 
01113 }                                /* BucketStart */

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 DoFill ( FILL_SPEC FillSpec,
CLASS_PRUNER  Pruner,
register UINT32  ClassMask,
register UINT32  ClassCount,
register UINT32  WordIndex 
)

Fills in the section of a class pruner corresponding to a single x value for a single proto of a class.

Parameters:
FillSpec Specifies which bits to fill in pruner
Pruner Class pruner to be filled
ClassMask Indicates which bits to change in each word
ClassCount Indicates what to change bits to
WordIndex Indicates which word to change
Returns:
none
Note:
Exceptions: none
Date:
Tue Feb 19 11:11:29 1991, DSJ, Created.

Definition at line 1151 of file intproto.cpp.

References FILL_SPEC::AngleEnd, FILL_SPEC::AngleStart, CircularIncrement, NUM_CP_BUCKETS, TRUE, FILL_SPEC::X, FILL_SPEC::YEnd, and FILL_SPEC::YStart.

Referenced by AddProtoToClassPruner().

01155                                        {
01156   register int X, Y, Angle;
01157   register UINT32 OldWord;
01158 
01159   X = FillSpec->X;
01160   if (X < 0)
01161     X = 0;
01162   if (X >= NUM_CP_BUCKETS)
01163     X = NUM_CP_BUCKETS - 1;
01164 
01165   if (FillSpec->YStart < 0)
01166     FillSpec->YStart = 0;
01167   if (FillSpec->YEnd >= NUM_CP_BUCKETS)
01168     FillSpec->YEnd = NUM_CP_BUCKETS - 1;
01169 
01170   for (Y = FillSpec->YStart; Y <= FillSpec->YEnd; Y++)
01171     for (Angle = FillSpec->AngleStart;
01172   TRUE; CircularIncrement (Angle, NUM_CP_BUCKETS)) {
01173     OldWord = Pruner[X][Y][Angle][WordIndex];
01174     if (ClassCount > (OldWord & ClassMask)) {
01175       OldWord &= ~ClassMask;
01176       OldWord |= ClassCount;
01177       Pruner[X][Y][Angle][WordIndex] = OldWord;
01178     }
01179     if (Angle == FillSpec->AngleEnd)
01180       break;
01181   }
01182 }                                /* DoFill */

BOOL8 FillerDone ( TABLE_FILLER Filler  ) 

Determines if specified table filler is done; if it has no more lines to fill.

Parameters:
Filler Table filler to check if done
Returns:
TRUE if no more lines to fill, FALSE otherwise.
Note:
Exceptions: none
Date:
Tue Feb 19 10:08:05 1991, DSJ, Created.

Definition at line 1195 of file intproto.cpp.

References FALSE, LastSwitch, TABLE_FILLER::NextSwitch, TABLE_FILLER::Switch, TRUE, FILL_SWITCH::Type, FILL_SWITCH::X, and TABLE_FILLER::X.

Referenced by AddProtoToClassPruner().

01195                                        { 
01196   FILL_SWITCH *Next;
01197 
01198   Next = &(Filler->Switch[Filler->NextSwitch]);
01199 
01200   if (Filler->X > Next->X && Next->Type == LastSwitch)
01201     return (TRUE);
01202   else
01203     return (FALSE);
01204 
01205 }                                /* FillerDone */

void FillPPCircularBits ( UINT32  ParamTable[NUM_PP_BUCKETS][WERDS_PER_PP_VECTOR],
int  Bit,
FLOAT32  Center,
FLOAT32  Spread 
)

Sets Bit in each bit vector whose bucket lies within the range Center +- Spread.

Parameters:
ParamTable Table of bit vectors, one per param bucket
Bit Bit position in vectors to be filled
Center Center of filled area
Spread Spread of filled area
Returns:
none
The fill is done for a circular dimension, i.e. bucket 0 is adjacent to the last bucket. It is assumed that Center and Spread are expressed in a circular coordinate system whose range is 0 to 1.
Note:
Exceptions: none
Date:
Tue Oct 16 09:26:54 1990, DSJ, Created.

Definition at line 1227 of file intproto.cpp.

References CircularIncrement, cprintf(), LearningDebugLevel, NUM_PP_BUCKETS, SET_BIT, and TRUE.

Referenced by AddProtoToProtoPruner().

01228                                          {
01229   int i, FirstBucket, LastBucket;
01230 
01231   if (Spread > 0.5)
01232     Spread = 0.5;
01233 
01234   FirstBucket = (int) floor ((Center - Spread) * NUM_PP_BUCKETS);
01235   if (FirstBucket < 0)
01236     FirstBucket += NUM_PP_BUCKETS;
01237 
01238   LastBucket = (int) floor ((Center + Spread) * NUM_PP_BUCKETS);
01239   if (LastBucket >= NUM_PP_BUCKETS)
01240     LastBucket -= NUM_PP_BUCKETS;
01241   if (LearningDebugLevel >= 2)
01242     cprintf ("Circular fill from %d to %d", FirstBucket, LastBucket);
01243   for (i = FirstBucket; TRUE; CircularIncrement (i, NUM_PP_BUCKETS)) {
01244     SET_BIT (ParamTable[i], Bit);
01245 
01246     /* exit loop after we have set the bit for the last bucket */
01247     if (i == LastBucket)
01248       break;
01249   }
01250 
01251 }                                /* FillPPCircularBits */

void FillPPLinearBits ( UINT32  ParamTable[NUM_PP_BUCKETS][WERDS_PER_PP_VECTOR],
int  Bit,
FLOAT32  Center,
FLOAT32  Spread 
)

Sets Bit in each bit vector whose bucket lies within the range Center +- Spread.

Parameters:
ParamTable Table of bit vectors, one per param bucket
Bit Bit number being filled
Center Center of filled area
Spread Spread of filled area
Returns:
none
The fill is done for a linear dimension, i.e. there is no wrap-around for this dimension. It is assumed that Center and Spread are expressed in a linear coordinate system whose range is approximately 0 to 1. Values outside this range will be clipped.
Note:
Exceptions: none
Date:
Tue Oct 16 09:26:54 1990, DSJ, Created.

Definition at line 1274 of file intproto.cpp.

References cprintf(), LearningDebugLevel, NUM_PP_BUCKETS, and SET_BIT.

Referenced by AddProtoToProtoPruner().

01275                                          {
01276   int i, FirstBucket, LastBucket;
01277 
01278   FirstBucket = (int) floor ((Center - Spread) * NUM_PP_BUCKETS);
01279   if (FirstBucket < 0)
01280     FirstBucket = 0;
01281 
01282   LastBucket = (int) floor ((Center + Spread) * NUM_PP_BUCKETS);
01283   if (LastBucket >= NUM_PP_BUCKETS)
01284     LastBucket = NUM_PP_BUCKETS - 1;
01285 
01286   if (LearningDebugLevel >= 2)
01287     cprintf ("Linear fill from %d to %d", FirstBucket, LastBucket);
01288   for (i = FirstBucket; i <= LastBucket; i++)
01289     SET_BIT (ParamTable[i], Bit);
01290 
01291 }                                /* FillPPLinearBits */

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  ) 

Prompts the user with Prompt and waits for the user to enter something in the debug window.

Parameters:
Prompt prompt to print while waiting for input from window
Returns:
Character entered in the debug window.
Note:
Exceptions: none
Date:
Thu Mar 21 16:55:13 1991, DSJ, Created.

Definition at line 1305 of file intproto.cpp.

References IntMatchWindow, and window_wait().

Referenced by AdaptToChar(), and DebugAdaptiveClassifier().

01305                                              { 
01306   return window_wait (IntMatchWindow);
01307 
01308 }                                /* GetClassToDebug */

void GetCPPadsForLevel ( int  Level,
FLOAT32 EndPad,
FLOAT32 SidePad,
FLOAT32 AnglePad 
)

Copies the appropriate global pad variables into EndPad, SidePad, and AnglePad.

Parameters:
Level The "tightness" level to return pads for
EndPad Place to put end pad for Level
SidePad Place to put side pad for Level
AnglePad Place to put angle pad for Level
Returns:
none (results are returned in EndPad, SidePad, and AnglePad.
This is a kludge used to get around the fact that global control variables cannot be arrays. If the specified level is illegal, the tightest possible pads are returned.
Note:
Exceptions: none
Date:
Thu Feb 14 08:26:49 1991, DSJ, Created.

Definition at line 1328 of file intproto.cpp.

References GetPicoFeatureLength.

Referenced by AddProtoToClassPruner().

01331                                           {
01332   switch (Level) {
01333     case 0:
01334       *EndPad = CPEndPadLoose * GetPicoFeatureLength ();
01335       *SidePad = CPSidePadLoose * GetPicoFeatureLength ();
01336       *AnglePad = CPAnglePadLoose / 360.0;
01337       break;
01338 
01339     case 1:
01340       *EndPad = CPEndPadMedium * GetPicoFeatureLength ();
01341       *SidePad = CPSidePadMedium * GetPicoFeatureLength ();
01342       *AnglePad = CPAnglePadMedium / 360.0;
01343       break;
01344 
01345     case 2:
01346       *EndPad = CPEndPadTight * GetPicoFeatureLength ();
01347       *SidePad = CPSidePadTight * GetPicoFeatureLength ();
01348       *AnglePad = CPAnglePadTight / 360.0;
01349       break;
01350 
01351     default:
01352       *EndPad = CPEndPadTight * GetPicoFeatureLength ();
01353       *SidePad = CPSidePadTight * GetPicoFeatureLength ();
01354       *AnglePad = CPAnglePadTight / 360.0;
01355       break;
01356   }
01357   if (*AnglePad > 0.5)
01358     *AnglePad = 0.5;
01359 
01360 }                                /* GetCPPadsForLevel */

C_COL GetMatchColorFor ( FLOAT32  Evidence  ) 

Returns color depending on evidence; different confidence is shown with a different color.

Parameters:
Evidence Evidence value to return color for
Returns:
Color which corresponds to specified Evidence value.
Note:
Exceptions: none
Date:
Thu Mar 21 15:24:52 1991, DSJ, Created.

Definition at line 1373 of file intproto.cpp.

References assert(), Blue, Green, Red, and White.

Referenced by DisplayIntFeature(), and DisplayIntProto().

01373                                          { 
01374   assert (Evidence >= 0.0);
01375   assert (Evidence <= 1.0);
01376 
01377   if (Evidence >= 0.90)
01378     return White;
01379   else if (Evidence >= 0.75)
01380     return Green;
01381   else if (Evidence >= 0.50)
01382     return Red;
01383   else
01384     return Blue;
01385 }                                /* GetMatchColorFor */

void GetNextFill ( TABLE_FILLER Filler,
FILL_SPEC Fill 
)

Returns (in Fill) the specification of the next line to be filled from Filler.

Parameters:
Filler Filler to get next fill spec from
Fill Place to put spec for next fill
Returns:
none (results are returned in Fill)
FillerDone() should always be called before GetNextFill() to ensure that we do not run past the end of the fill table.
Note:
Exceptions: none
Date:
Tue Feb 19 10:17:42 1991, DSJ, Created.

Definition at line 1402 of file intproto.cpp.

References TABLE_FILLER::AngleEnd, FILL_SPEC::AngleEnd, TABLE_FILLER::AngleStart, FILL_SPEC::AngleStart, FILL_SWITCH::Delta, TABLE_FILLER::EndDelta, EndSwitch, TABLE_FILLER::NextSwitch, TABLE_FILLER::StartDelta, StartSwitch, TABLE_FILLER::Switch, FILL_SWITCH::Type, FILL_SWITCH::X, TABLE_FILLER::X, FILL_SPEC::X, FILL_SWITCH::Y, TABLE_FILLER::YEnd, FILL_SPEC::YEnd, FILL_SWITCH::YInit, TABLE_FILLER::YStart, and FILL_SPEC::YStart.

Referenced by AddProtoToClassPruner().

01402                                                         { 
01403   FILL_SWITCH *Next;
01404 
01405   /* compute the fill assuming no switches will be encountered */
01406   Fill->AngleStart = Filler->AngleStart;
01407   Fill->AngleEnd = Filler->AngleEnd;
01408   Fill->X = Filler->X;
01409   Fill->YStart = Filler->YStart >> 8;
01410   Fill->YEnd = Filler->YEnd >> 8;
01411 
01412   /* update the fill info and the filler for ALL switches at this X value */
01413   Next = &(Filler->Switch[Filler->NextSwitch]);
01414   while (Filler->X >= Next->X) {
01415     Fill->X = Filler->X = Next->X;
01416     if (Next->Type == StartSwitch) {
01417       Fill->YStart = Next->Y;
01418       Filler->StartDelta = Next->Delta;
01419       Filler->YStart = Next->YInit;
01420     }
01421     else if (Next->Type == EndSwitch) {
01422       Fill->YEnd = Next->Y;
01423       Filler->EndDelta = Next->Delta;
01424       Filler->YEnd = Next->YInit;
01425     }
01426     else {                       /* Type must be LastSwitch */
01427       break;
01428     }
01429     Filler->NextSwitch++;
01430     Next = &(Filler->Switch[Filler->NextSwitch]);
01431   }
01432 
01433   /* prepare the filler for the next call to this routine */
01434   Filler->X++;
01435   Filler->YStart += Filler->StartDelta;
01436   Filler->YEnd += Filler->EndDelta;
01437 
01438 }                                /* GetNextFill */

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 */

void InitTableFiller ( FLOAT32  EndPad,
FLOAT32  SidePad,
FLOAT32  AnglePad,
PROTO  Proto,
TABLE_FILLER Filler 
)

Computes a data structure (Filler) which can be used to fill in a rectangle surrounding the specified Proto.

Parameters:
EndPad Padding to add to proto
SidePad Padding to add to proto
AnglePad Padding to add to proto
Proto Proto to create a filler for
Filler Place to put table filler
Returns:
none (results are returned in Filler)
InitTableFiller() implements the set of equations listed in Patent 5,237,627 in Column 6, Row 35 to 50.

Note:
Exceptions: none
Date:
Thu Feb 14 09:27:05 1991, DSJ, Created.

Definition at line 1460 of file intproto.cpp.

References TABLE_FILLER::AngleEnd, TABLE_FILLER::AngleStart, AS, BucketEnd(), BucketFor(), BucketStart(), CircBucketFor(), FILL_SWITCH::Delta, TABLE_FILLER::EndDelta, EndSwitch, HV_TOLERANCE, LastSwitch, MapParam, NB, TABLE_FILLER::NextSwitch, PI, ProtoAngle, ProtoLength, ProtoX, ProtoY, TABLE_FILLER::StartDelta, StartSwitch, TABLE_FILLER::Switch, FILL_SWITCH::Type, FPOINT::x, FILL_SWITCH::X, TABLE_FILLER::X, XS, FILL_SWITCH::Y, FPOINT::y, TABLE_FILLER::YEnd, FILL_SWITCH::YInit, YS, and TABLE_FILLER::YStart.

Referenced by AddProtoToClassPruner().

01467 {
01468   FLOAT32 Angle;
01469   FLOAT32 X, Y, HalfLength;
01470   FLOAT32 Cos, Sin;
01471   FLOAT32 XAdjust, YAdjust;
01472   FPOINT Start, Switch1, Switch2, End;
01473   int S1 = 0;
01474   int S2 = 1;
01475 
01476   Angle = ProtoAngle (Proto);
01477   X = ProtoX (Proto);
01478   Y = ProtoY (Proto);
01479   HalfLength = ProtoLength (Proto) / 2.0;
01480 
01481   Filler->AngleStart = CircBucketFor (Angle - AnglePad, AS, NB);
01482   Filler->AngleEnd = CircBucketFor (Angle + AnglePad, AS, NB);
01483   Filler->NextSwitch = 0;
01484 
01485   if (fabs (Angle - 0.0) < HV_TOLERANCE || fabs (Angle - 0.5) < HV_TOLERANCE) {
01486     /* horizontal proto - handle as special case */
01487     Filler->X = BucketFor (X - HalfLength - EndPad, XS, NB);
01488     Filler->YStart = BucketFor (Y - SidePad, YS, NB * 256);
01489     Filler->YEnd = BucketFor (Y + SidePad, YS, NB * 256);
01490     Filler->StartDelta = 0;
01491     Filler->EndDelta = 0;
01492     Filler->Switch[0].Type = LastSwitch;
01493     Filler->Switch[0].X = BucketFor (X + HalfLength + EndPad, XS, NB);
01494   }
01495   else if (fabs (Angle - 0.25) < HV_TOLERANCE ||
01496   fabs (Angle - 0.75) < HV_TOLERANCE) {
01497     /* vertical proto - handle as special case */
01498     Filler->X = BucketFor (X - SidePad, XS, NB);
01499     Filler->YStart = BucketFor (Y - HalfLength - EndPad, YS, NB * 256);
01500     Filler->YEnd = BucketFor (Y + HalfLength + EndPad, YS, NB * 256);
01501     Filler->StartDelta = 0;
01502     Filler->EndDelta = 0;
01503     Filler->Switch[0].Type = LastSwitch;
01504     Filler->Switch[0].X = BucketFor (X + SidePad, XS, NB);
01505   }
01506   else {
01507     /* diagonal proto */
01508 
01509     if (Angle > 0.0 && Angle < 0.25 || Angle > 0.5 && Angle < 0.75) {
01510       /* rising diagonal proto */
01511       Angle *= 2.0 * PI;
01512       Cos = fabs (cos (Angle));
01513       Sin = fabs (sin (Angle));
01514 
01515       /* compute the positions of the corners of the acceptance region */
01516       Start.x = X - (HalfLength + EndPad) * Cos - SidePad * Sin;
01517       Start.y = Y - (HalfLength + EndPad) * Sin + SidePad * Cos;
01518       End.x = 2.0 * X - Start.x;
01519       End.y = 2.0 * Y - Start.y;
01520       Switch1.x = X - (HalfLength + EndPad) * Cos + SidePad * Sin;
01521       Switch1.y = Y - (HalfLength + EndPad) * Sin - SidePad * Cos;
01522       Switch2.x = 2.0 * X - Switch1.x;
01523       Switch2.y = 2.0 * Y - Switch1.y;
01524 
01525       if (Switch1.x > Switch2.x) {
01526         S1 = 1;
01527         S2 = 0;
01528       }
01529 
01530       /* translate into bucket positions and deltas */
01531       Filler->X = (INT8) MapParam (Start.x, XS, NB);
01532       Filler->StartDelta = -(INT16) ((Cos / Sin) * 256);
01533       Filler->EndDelta = (INT16) ((Sin / Cos) * 256);
01534 
01535       XAdjust = BucketEnd (Filler->X, XS, NB) - Start.x;
01536       YAdjust = XAdjust * Cos / Sin;
01537       Filler->YStart = (INT16) MapParam (Start.y - YAdjust, YS, NB * 256);
01538       YAdjust = XAdjust * Sin / Cos;
01539       Filler->YEnd = (INT16) MapParam (Start.y + YAdjust, YS, NB * 256);
01540 
01541       Filler->Switch[S1].Type = StartSwitch;
01542       Filler->Switch[S1].X = (INT8) MapParam (Switch1.x, XS, NB);
01543       Filler->Switch[S1].Y = (INT8) MapParam (Switch1.y, YS, NB);
01544       XAdjust = Switch1.x - BucketStart (Filler->Switch[S1].X, XS, NB);
01545       YAdjust = XAdjust * Sin / Cos;
01546       Filler->Switch[S1].YInit =
01547         (INT16) MapParam (Switch1.y - YAdjust, YS, NB * 256);
01548       Filler->Switch[S1].Delta = Filler->EndDelta;
01549 
01550       Filler->Switch[S2].Type = EndSwitch;
01551       Filler->Switch[S2].X = (INT8) MapParam (Switch2.x, XS, NB);
01552       Filler->Switch[S2].Y = (INT8) MapParam (Switch2.y, YS, NB);
01553       XAdjust = Switch2.x - BucketStart (Filler->Switch[S2].X, XS, NB);
01554       YAdjust = XAdjust * Cos / Sin;
01555       Filler->Switch[S2].YInit =
01556         (INT16) MapParam (Switch2.y + YAdjust, YS, NB * 256);
01557       Filler->Switch[S2].Delta = Filler->StartDelta;
01558 
01559       Filler->Switch[2].Type = LastSwitch;
01560       Filler->Switch[2].X = (INT8) MapParam (End.x, XS, NB);
01561     }
01562     else {
01563       /* falling diagonal proto */
01564       Angle *= 2.0 * PI;
01565       Cos = fabs (cos (Angle));
01566       Sin = fabs (sin (Angle));
01567 
01568       /* compute the positions of the corners of the acceptance region */
01569       Start.x = X - (HalfLength + EndPad) * Cos - SidePad * Sin;
01570       Start.y = Y + (HalfLength + EndPad) * Sin - SidePad * Cos;
01571       End.x = 2.0 * X - Start.x;
01572       End.y = 2.0 * Y - Start.y;
01573       Switch1.x = X - (HalfLength + EndPad) * Cos + SidePad * Sin;
01574       Switch1.y = Y + (HalfLength + EndPad) * Sin + SidePad * Cos;
01575       Switch2.x = 2.0 * X - Switch1.x;
01576       Switch2.y = 2.0 * Y - Switch1.y;
01577 
01578       if (Switch1.x > Switch2.x) {
01579         S1 = 1;
01580         S2 = 0;
01581       }
01582 
01583       /* translate into bucket positions and deltas */
01584       Filler->X = (INT8) MapParam (Start.x, XS, NB);
01585       Filler->StartDelta = -(INT16) ((Sin / Cos) * 256);
01586       Filler->EndDelta = (INT16) ((Cos / Sin) * 256);
01587 
01588       XAdjust = BucketEnd (Filler->X, XS, NB) - Start.x;
01589       YAdjust = XAdjust * Sin / Cos;
01590       Filler->YStart = (INT16) MapParam (Start.y - YAdjust, YS, NB * 256);
01591       YAdjust = XAdjust * Cos / Sin;
01592       Filler->YEnd = (INT16) MapParam (Start.y + YAdjust, YS, NB * 256);
01593 
01594       Filler->Switch[S1].Type = EndSwitch;
01595       Filler->Switch[S1].X = (INT8) MapParam (Switch1.x, XS, NB);
01596       Filler->Switch[S1].Y = (INT8) MapParam (Switch1.y, YS, NB);
01597       XAdjust = Switch1.x - BucketStart (Filler->Switch[S1].X, XS, NB);
01598       YAdjust = XAdjust * Sin / Cos;
01599       Filler->Switch[S1].YInit =
01600         (INT16) MapParam (Switch1.y + YAdjust, YS, NB * 256);
01601       Filler->Switch[S1].Delta = Filler->StartDelta;
01602 
01603       Filler->Switch[S2].Type = StartSwitch;
01604       Filler->Switch[S2].X = (INT8) MapParam (Switch2.x, XS, NB);
01605       Filler->Switch[S2].Y = (INT8) MapParam (Switch2.y, YS, NB);
01606       XAdjust = Switch2.x - BucketStart (Filler->Switch[S2].X, XS, NB);
01607       YAdjust = XAdjust * Cos / Sin;
01608       Filler->Switch[S2].YInit =
01609         (INT16) MapParam (Switch2.y - YAdjust, YS, NB * 256);
01610       Filler->Switch[S2].Delta = Filler->EndDelta;
01611 
01612       Filler->Switch[2].Type = LastSwitch;
01613       Filler->Switch[2].X = (INT8) MapParam (End.x, XS, NB);
01614     }
01615   }
01616 }                                /* InitTableFiller */

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 RenderIntFeature ( void *  window,
INT_FEATURE  Feature,
C_COL  Color 
)

Renders the specified feature into ShapeList.

Parameters:
window Window handle
Feature Feature to be rendered
Color Color to use for feature rendering
Returns:
New shape list with rendering of Feature added.
Note:
Exceptions: none
Date:
Thu Mar 21 14:57:41 1991, DSJ, Created.

Definition at line 1631 of file intproto.cpp.

References assert(), c_draw(), c_line_color_index(), c_move(), DISPLAY_OFFSET, DOUBLE_OFFSET, GetPicoFeatureLength, INT_CHAR_NORM_RANGE, NULL, PI, INT_FEATURE_STRUCT::Theta, INT_FEATURE_STRUCT::X, and INT_FEATURE_STRUCT::Y.

Referenced by DisplayIntFeature().

01631                                                                       { 
01632   FLOAT32 X, Y, Dx, Dy, Length;
01633 
01634   c_line_color_index(window, Color);
01635   assert (Feature != NULL);
01636   assert (Color != 0);
01637 
01638   X = Feature->X - DISPLAY_OFFSET;
01639   Y = Feature->Y - DISPLAY_OFFSET;
01640   Length = GetPicoFeatureLength () * 0.7 * INT_CHAR_NORM_RANGE;
01641   Dx = (Length / 2.0) * cos ((Feature->Theta / 256.0) * 2.0 * PI);
01642   Dy = (Length / 2.0) * sin ((Feature->Theta / 256.0) * 2.0 * PI);
01643 
01644   c_move (window, X - Dx, Y - Dy);
01645   c_draw (window, X + Dx, Y + Dy);
01646   c_move (window, X - Dx - Dy * DOUBLE_OFFSET, Y - Dy + Dx * DOUBLE_OFFSET);
01647   c_draw (window, X + Dx - Dy * DOUBLE_OFFSET, Y + Dy + Dx * DOUBLE_OFFSET);
01648 }                                /* RenderIntFeature */

void RenderIntProto ( void *  window,
INT_CLASS  Class,
PROTO_ID  ProtoId,
C_COL  Color 
)

Extracts the parameters of the specified proto from the class description and adds a rendering of the proto onto the ShapeList.

Parameters:
window Window handle
Class Class that proto is contained in
ProtoId Id of proto to be rendered
Color Color to render proto in
Returns:
New shape list with a rendering of one proto added.
Note:
Exceptions: none
Date:
Thu Mar 21 10:21:09 1991, DSJ, Created.

Definition at line 1665 of file intproto.cpp.

References assert(), c_draw(), c_line_color_index(), c_move(), DISPLAY_OFFSET, GetPicoFeatureLength, IndexForProto, INT_CHAR_NORM_RANGE, LengthForProtoId, NULL, NUM_PP_BUCKETS, NumIntProtosIn, PI, PPrunerMaskFor, PPrunerWordIndexFor, PROTO_PRUNER_SCALE, ProtoSetIn, PRUNER_X, PRUNER_Y, and SetForProto.

Referenced by DisplayIntProto().

01668                                  {
01669   PROTO_SET ProtoSet;
01670   INT_PROTO Proto;
01671   int ProtoSetIndex;
01672   int ProtoWordIndex;
01673   FLOAT32 Length;
01674   int Xmin, Xmax, Ymin, Ymax;
01675   FLOAT32 X, Y, Dx, Dy;
01676   UINT32 ProtoMask;
01677   int Bucket;
01678 
01679   assert (ProtoId >= 0);
01680   assert (Class != NULL);
01681   assert (ProtoId < NumIntProtosIn (Class));
01682   assert (Color != 0);
01683   c_line_color_index(window, Color);
01684 
01685   ProtoSet = ProtoSetIn (Class, SetForProto (ProtoId));
01686   ProtoSetIndex = IndexForProto (ProtoId);
01687   Proto = &(ProtoSet->Protos[ProtoSetIndex]);
01688   Length = (LengthForProtoId (Class, ProtoId) *
01689     GetPicoFeatureLength () * INT_CHAR_NORM_RANGE);
01690   ProtoMask = PPrunerMaskFor (ProtoId);
01691   ProtoWordIndex = PPrunerWordIndexFor (ProtoId);
01692 
01693   // find the x and y extent of the proto from the proto pruning table
01694   Xmin = Ymin = NUM_PP_BUCKETS;
01695   Xmax = Ymax = 0;
01696   for (Bucket = 0; Bucket < NUM_PP_BUCKETS; Bucket++) {
01697     if (ProtoMask & ProtoSet->ProtoPruner[PRUNER_X][Bucket][ProtoWordIndex])
01698       if (Bucket < Xmin)
01699         Xmin = Bucket;
01700     else if (Bucket > Xmax)
01701       Xmax = Bucket;
01702 
01703     if (ProtoMask & ProtoSet->ProtoPruner[PRUNER_Y][Bucket][ProtoWordIndex])
01704       if (Bucket < Ymin)
01705         Ymin = Bucket;
01706     else if (Bucket > Ymax)
01707       Ymax = Bucket;
01708   }
01709   X = (Xmin + Xmax + 1) / 2.0 * PROTO_PRUNER_SCALE - DISPLAY_OFFSET;
01710   Y = (Ymin + Ymax + 1) / 2.0 * PROTO_PRUNER_SCALE - DISPLAY_OFFSET;
01711   Dx = (Length / 2.0) * cos ((Proto->Angle / 256.0) * 2.0 * PI);
01712   Dy = (Length / 2.0) * sin ((Proto->Angle / 256.0) * 2.0 * PI);
01713 
01714   c_move (window, X - Dx, Y - Dy);
01715   c_draw (window, X + Dx, Y + Dy);
01716 }                                /* RenderIntProto */

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 */

int TruncateParam ( FLOAT32  Param,
int  Min,
int  Max,
char *  Id 
)

Truncates Param to lie within the range of Min-Max inclusive.

Parameters:
Param Parameter value to be truncated
Min Parameter limits (inclusive)
Max Parameter limits (inclusive)
Id String id of parameter for error messages
Returns:
Truncated parameter.
If a truncation is performed, and Id is not null, an warning message is printed.
Note:
Exceptions: none
Date:
Fri Feb 8 11:54:28 1991, DSJ, Created.

Definition at line 1734 of file intproto.cpp.

References cprintf().

Referenced by ConvertProto().

01734                                                              { 
01735   if (Param < Min) {
01736     if (Id)
01737       cprintf ("Warning: Param %s truncated from %f to %d!\n",
01738         Id, Param, Min);
01739     Param = Min;
01740   }
01741   else if (Param > Max) {
01742     if (Id)
01743       cprintf ("Warning: Param %s truncated from %f to %d!\n",
01744         Id, Param, Max);
01745     Param = Max;
01746   }
01747   return (int) floor (Param);
01748 
01749 }                                /* TruncateParam */

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 */


Variable Documentation

void* IntMatchWindow = NULL

global display lists used to display proto and feature match information

Definition at line 273 of file intproto.cpp.

Referenced by DisplayIntFeature(), DisplayIntProto(), GetClassToDebug(), IMDisplayProtoDebugInfo(), ShowMatchDisplay(), and UpdateMatchDisplay().


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