// DlmSimilarity.h const int gallerySizeMax = 5+1; // maximal possible size of the gallery + 1 ; #ifdef NSL_PC static const double M_PI = 3.141592654; #endif class DlmCommon : public NslModule { public: DlmCommon(nsl_string, NslModule*); ~DlmCommon() {} protected: int i1Index(int, int, int,int,int,int); int j1Index(int, int, int,int,int,int); int i1RIndex(int, int, int,int,int,int); int j1RIndex(int, int, int,int,int,int); }; /* For objects and models there are stored graphs with the precomputed Gabor-wavelet transform coefficients. For the models they are taken from a grid of 10 x 10 nodes centered on the faces. For the objects the grids cover the whole image plane with 16 x 17 nodes. From these stored graphs a subgraph can be selected. From the 16 x 17 graph for example a 12 x 12 subgraph will automatically be selected if the size of layer 1 is 12 x 12. In addition one can choose the location of the subgraph by the offsets Si1offset, ... , and Sj2offset. They are given as integer numbers behind the model names in the gallery files. */ class DlmSimilarity : public DlmCommon { public: NslDoutFloat4 sim[gallerySizeMax]; // similarity matrix from layer 1 to layers 2 ; NslFloat1 DlmImageModelData[gallerySizeMax]; private: nsl_file DlmObjects; nsl_file DlmGraph; nsl_file DlmModels; NslFloat1 DlmGImage; NslFloat2 ImageNormChar; NslFloat1 DlmGModel; NslFloat2 ModelNormFloat; NslFloat2 ModelNormChar; NslInt0 gallerySize; int frame; // width of the frame around layer 1 int i1max; // size of the image layer 1, including frame; int j1max; int i2max; // size of the model layers 2 ; int j2max; int i1Rmax; // size of the projection patches .. ; int j1Rmax; // ... from model layer 2 to image layer 1 ; int Si2offset, Sj2offset, Si1offset, Sj1offset, Oi1offset, Oj1offset; int selectedObject; NslString0 objectsFileName; NslString0 modelsFileName; NslString0 objectName; // name of the image graph file ; int kLevels, kDirections; int kLevelsTmp, kDirectionsTmp; float kMaximum, kFactor, sigma; float kMaximumTmp, kFactorTmp, sigmaTmp; int tablesCreated; NslFloat1 kxArr; NslFloat1 kyArr; NslFloat1 confidenceBak; NslFloat1 deltaPhaseBak; NslInt0 ObjectSelectionMode; NslInt0 preferredObject; NslFloat0 alpha_S; // minimal synaptic weight ; NslString0 modelName[gallerySizeMax]; // names of model graph files ; public: DlmSimilarity(nsl_string,NslModule*); ~DlmSimilarity() {} void initModule(); void memAlloc(int,int,int,int,int,int,int); void initSys(); void createTables(); float similarity(NslFloat1&,int, int, NslFloat1&,int, int); };