NPclassify.H

Go to the documentation of this file.
00001 /*!@file VFAT/NPclassify.H  Test the nonparametric classifier
00002  */
00003 
00004 // //////////////////////////////////////////////////////////////////// //
00005 // The iLab Neuromorphic Vision C++ Toolkit - Copyright (C) 2001 by the //
00006 // University of Southern California (USC) and the iLab at USC.         //
00007 // See http://iLab.usc.edu for information about this project.          //
00008 // //////////////////////////////////////////////////////////////////// //
00009 // Major portions of the iLab Neuromorphic Vision Toolkit are protected //
00010 // under the U.S. patent ``Computation of Intrinsic Perceptual Saliency //
00011 // in Visual Environments, and Applications'' by Christof Koch and      //
00012 // Laurent Itti, California Institute of Technology, 2001 (patent       //
00013 // pending; application number 09/912,225 filed July 23, 2001; see      //
00014 // http://pair.uspto.gov/cgi-bin/final/home.pl for current status).     //
00015 // //////////////////////////////////////////////////////////////////// //
00016 // This file is part of the iLab Neuromorphic Vision C++ Toolkit.       //
00017 //                                                                      //
00018 // The iLab Neuromorphic Vision C++ Toolkit is free software; you can   //
00019 // redistribute it and/or modify it under the terms of the GNU General  //
00020 // Public License as published by the Free Software Foundation; either  //
00021 // version 2 of the License, or (at your option) any later version.     //
00022 //                                                                      //
00023 // The iLab Neuromorphic Vision C++ Toolkit is distributed in the hope  //
00024 // that it will be useful, but WITHOUT ANY WARRANTY; without even the   //
00025 // implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR      //
00026 // PURPOSE.  See the GNU General Public License for more details.       //
00027 //                                                                      //
00028 // You should have received a copy of the GNU General Public License    //
00029 // along with the iLab Neuromorphic Vision C++ Toolkit; if not, write   //
00030 // to the Free Software Foundation, Inc., 59 Temple Place, Suite 330,   //
00031 // Boston, MA 02111-1307 USA.                                           //
00032 // //////////////////////////////////////////////////////////////////// //
00033 //
00034 // Primary maintainer for this file: T Nathan Mundhenk <mundhenk@usc.edu>
00035 // $HeadURL: svn://isvn.usc.edu/software/invt/trunk/saliency/src/VFAT/NPclassify.H $
00036 // $Id: NPclassify.H 6393 2006-03-26 00:57:36Z rjpeters $
00037 //
00038 
00039 #ifndef NPCLASSIFY_H_DEFINED
00040 #define NPCLASSIFY_H_DEFINED
00041 
00042 #include <vector>
00043 #include "Util/readConfig.H"
00044 
00045 class NPclassify
00046 {
00047 private:
00048   std::vector<long> children;
00049   std::vector<long> parent;
00050   std::vector<long> childMapTot;
00051   std::vector<long> childMapTotLast;
00052   std::vector<long> stem;
00053   std::vector<long> root;
00054   std::vector<long> master;
00055   std::vector<long> masterIndex;
00056   std::vector<long> classSize;
00057   std::vector<long> childInterCount;
00058   std::vector<long> idealLinks;
00059   //! density for this point
00060   std::vector<double> density;
00061   std::vector<double> distance;
00062   std::vector<double> meanInterDistance;
00063   std::vector<double> meanInterChild;
00064   std::vector<double> meanInterDensity;
00065   std::vector<double> stdInterDistance;
00066   std::vector<double> stdInterDensity;
00067   std::vector<double> stdInterChild;
00068   std::vector<double> trainMeasure;
00069   //! am I a stem for this class
00070   std::vector<bool> revStem;
00071   std::vector<bool> childMapDone;
00072   std::vector<bool> lowDensity;
00073   std::vector<bool> selected;
00074   std::vector< std::vector<long> > child;
00075   std::vector< std::vector<long> > childMap;
00076   std::vector< std::vector<long> > childInterMap;
00077   std::vector< std::vector<long> > Class;
00078   std::vector< std::vector<double> > D;
00079   std::vector< std::vector<double> > Dis;
00080   std::vector< std::vector<double> > Space;
00081   long spaceSize,stems,roots,iteration,defaultSize;
00082   long minDist,minChild;
00083   long hardClassSize,hardLinkSize;
00084   double distanceCut, childCut;
00085   double maxDensity,trainChildWeight;
00086   double Con1,Con2,Con3;
00087   double sumSquares,sum;
00088   double meanDistance,stdDistance,meanChildren,stdChildren;
00089   double meanChildMap,stdChildMap,meanDensity,stdDensity;
00090   double DWeight1, CWeight1, IDWeight1, ICWeight1;
00091   double DWeight2, CWeight2, IDWeight2, ICWeight2;
00092   double DenWeight1, DenWeight2, preDenWeight1, preDenWeight2;
00093   double thresh1,thresh2,thresh3,thresh4,measure1,measure2;
00094   bool notDone;
00095   double polyDensObjectCut1,polyDensObjectCut2,polyDensObjectCut3;
00096   double polySpaceChildCut1,polySpaceChildCut2,polySpaceChildCut3;
00097   bool CLS;
00098 
00099   // *****************************************
00100   // PRIVATE METHODS
00101   // *****************************************
00102   //! convolve your space (first method)
00103   void convolveSpace();
00104   //! convolve your space (revision 1)
00105   void convolveSpace2();
00106   //! link your points together
00107   void linkSpace();
00108   //! map space. Who is below me
00109   void mapSpace();
00110   //! run your analisys on the space group based upon group weights, on length
00111   void analizeSpace();
00112   //! cut lengths, link groups, traverse tree
00113   void evolveSpace();
00114   //! find interclass variance
00115   void analizeInterSpace();
00116   //! evolve space again using interclass variance
00117   void evolveInterSpace();
00118   //! computes the master lists of all points in classes
00119   void computeMasters();
00120   //! resizes all vectors if more space is added
00121   void resizeSpace();
00122 public:
00123   int doLinkMap,doDensityMap,doClassMap,usePolySet;
00124   // *****************************************
00125   // PUBLIC METHODS
00126   // *****************************************
00127   //! create object with readConfig as defaults
00128   NPclassify(readConfig &settings, readConfig &polySet,
00129              bool commandLineSettings = false);
00130   ~NPclassify();
00131   //! input command line settings for some variables insted of using .conf
00132   void inputCommandLineSettings(double _distance, double _children,
00133                                double Idistance, double Ichildren,
00134                                long _hardClassSize, long _hardLinkSize,
00135                                double _polyDensObjectCut1,
00136                                double _polyDensObjectCut2,
00137                                double _polyDensObjectCut3);
00138   //! add a point to the space
00139   void addPoint(std::vector<long> point);
00140   //! add whole space (concatinates if data is there)
00141   /*!
00142     @param space This is a set of feature vectors as a vector of vectors
00143     @param sSize This is how many elements you are adding leave blank if \
00144     the number of elements equals the vector size
00145   */
00146   void addSpace(std::vector<std::vector<double> > &space,long sSize = 0);
00147   //! echo the space you are working in
00148   void echoSpace();
00149   //! reset the dataset to empty (dose not resize vectors)
00150   void resetSpace();
00151   //! classify space based upon rules given, for the first time
00152   void classifySpaceNew();
00153   //! classify space using K-Means
00154   void classifySpaceKmeans(unsigned int K);
00155   //! classify space in subsequent iterations
00156   void classifySpacePartial();
00157   //! return how many stems there are (how many classes)
00158   long getStemNumber();
00159   //! return the max density value
00160   double getMaxDensity();
00161   //! return if this point is a low density point
00162   bool isLowDensity(long item);
00163   //! return if this item is a stem
00164   bool isStem(long item);
00165   //! return density weight map (linear)
00166   std::vector<double> getDensity();
00167   //! Returns a vector of all class parents
00168   std::vector<long> getStems();
00169   //! Return how many points/vectors are in class n (1... n)
00170   long getClassSize(long _Class);
00171   //! return what is set as the minimum class size
00172   long getMinClassSize();
00173   //! Return class n as a vector (Set of all points/vectors in this class)
00174   std::vector<long> getClass(long _Class);
00175   //! Return item n from class m
00176   long getClass(long _Class, long item);
00177   //! Return feature m of vector n
00178   double getFeature(long m_feature_index, long n_vector_index);
00179   //! returns parents
00180   std::vector<long> getParents();
00181   //! Returns a vector of all decendants (children, grandchildren) or all nodes
00182   std::vector<std::vector<long> > getChildren();
00183   //! calculate and return simple bounding boxes for classes
00184   std::vector<std::vector<long> > getBoundingBoxes();
00185   //! analyze classification stratagy. create meta classifier
00186   void metaClassify(int objects);
00187 };
00188 
00189 #endif
00190 
00191 
00192 // ######################################################################
00193 /* So things look consistent in everyone's emacs... */
00194 /* Local Variables: */
00195 /* indent-tabs-mode: nil */
00196 /* End: */
Generated on Sun May 8 08:07:03 2011 for iLab Neuromorphic Vision Toolkit by  doxygen 1.6.3