00001 /*!@file Surprise/SurpriseMap.H a surprise map */ 00002 00003 // //////////////////////////////////////////////////////////////////// // 00004 // The iLab Neuromorphic Vision C++ Toolkit - Copyright (C) 2000-2003 // 00005 // by the University of Southern California (USC) and the iLab at USC. // 00006 // See http://iLab.usc.edu for information about this project. // 00007 // //////////////////////////////////////////////////////////////////// // 00008 // Major portions of the iLab Neuromorphic Vision Toolkit are protected // 00009 // under the U.S. patent ``Computation of Intrinsic Perceptual Saliency // 00010 // in Visual Environments, and Applications'' by Christof Koch and // 00011 // Laurent Itti, California Institute of Technology, 2001 (patent // 00012 // pending; application number 09/912,225 filed July 23, 2001; see // 00013 // http://pair.uspto.gov/cgi-bin/final/home.pl for current status). // 00014 // //////////////////////////////////////////////////////////////////// // 00015 // This file is part of the iLab Neuromorphic Vision C++ Toolkit. // 00016 // // 00017 // The iLab Neuromorphic Vision C++ Toolkit is free software; you can // 00018 // redistribute it and/or modify it under the terms of the GNU General // 00019 // Public License as published by the Free Software Foundation; either // 00020 // version 2 of the License, or (at your option) any later version. // 00021 // // 00022 // The iLab Neuromorphic Vision C++ Toolkit is distributed in the hope // 00023 // that it will be useful, but WITHOUT ANY WARRANTY; without even the // 00024 // implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR // 00025 // PURPOSE. See the GNU General Public License for more details. // 00026 // // 00027 // You should have received a copy of the GNU General Public License // 00028 // along with the iLab Neuromorphic Vision C++ Toolkit; if not, write // 00029 // to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, // 00030 // Boston, MA 02111-1307 USA. // 00031 // //////////////////////////////////////////////////////////////////// // 00032 // 00033 // Primary maintainer for this file: Laurent Itti <itti@usc.edu> 00034 // $HeadURL: svn://isvn.usc.edu/software/invt/trunk/saliency/src/Surprise/SurpriseMap.H $ 00035 // $Id: SurpriseMap.H 10147 2008-08-27 03:01:00Z mundhenk $ 00036 // 00037 00038 #ifndef SURPRISEMAP_H_DEFINED 00039 #define SURPRISEMAP_H_DEFINED 00040 00041 #define SUP_STD_MODEL 1 00042 #define SUP_COV_MODEL 2 00043 00044 #include "Image/Image.H" 00045 #include "Image/ImageCache.H" 00046 #include "Surprise/SurpriseImage.H" 00047 #include "Surprise/SurpriseModel.H" 00048 #include <vector> 00049 #include <typeinfo> 00050 00051 // ###################################################################### 00052 //! A Surprise Map 00053 /*! This class contains a SurpriseImage of our current models at each 00054 pixel, plus an ImageCache of SurpriseImage objects built to 00055 represent the neighborhood distributions. */ 00056 template <class T> 00057 class SurpriseMap 00058 { 00059 public: 00060 //! Constructor; you must call init() before using 00061 SurpriseMap(); 00062 00063 //! initialization 00064 /*! @param qlen number of maps 00065 @param updatefac factor by which the current model is combined with 00066 a new model on an update. Valid values are in [0..1] 00067 @param neighupdatefac factor by which local data is combined with 00068 neighborhood models, or 0.0 to use the value of updatefac 00069 @param sampleval the value of the samples previously received. 00070 @param samplevar a variance expressing the intrinsic variability 00071 in the measurement of those samples. 00072 @param neighsigma sigma to use for the neighborhoods as a fraction of 00073 max(map width, map height) 00074 @param locsigma sigma to use for local neighborhood, in pixels */ 00075 void init(const uint qlen = 1, const double updatefac = 0.7, 00076 const double neighupdatefac = 0.7, 00077 const double sampleval = 0.0, const double samplevar = 1.0, 00078 const float neighsigma = 0.5f, const float locsigma = 3.0f, 00079 const Point2D<int>& probe = Point2D<int>(-1, -1), 00080 const double slfac = 1.0, const double ssfac = 0.1, 00081 const SU_KL_BIAS = SU_KL_NONE, 00082 const bool takeSTMax = false); 00083 00084 //! Virtual destructor ensures proper destruction of derived classes 00085 ~SurpriseMap(); 00086 00087 //! Reset to initial state 00088 void reset(); 00089 00090 //! reset and create empty surprise models for temporal surprise 00091 void initModels(const SurpriseImage<T>& sample, 00092 const bool setBias = false); 00093 00094 //! Update by receiving a new sample and sample measurement error 00095 /*! The returned image is the surprise (combined temporal and 00096 spatial for each map, then combined over all maps) resulting from 00097 that update. NOTE: SurpriseModelPM has a special implementation, other 00098 surprise models follow the generic template implementation. */ 00099 Image<double> surprise(const SurpriseImage<T>& sample); 00100 00101 //! Access to underlying SurpriseImage members: 00102 const SurpriseImage<T>& getSurpriseImage(const uint index) const; 00103 00104 private: 00105 std::vector< SurpriseImage<T> > itsModels; 00106 uint itsQlen; 00107 T itsInitialModel; 00108 float itsNeighSigma, itsLocSigma; 00109 Image<float> itsNweights; 00110 float itsNWmin; 00111 double itsNeighUpdFac; 00112 Point2D<int> itsProbe; 00113 double itsSLfac, itsSSfac; 00114 SU_KL_BIAS itsJointKLBiasType; 00115 bool itsTakeSTMax; 00116 }; 00117 00118 #endif 00119 00120 // ###################################################################### 00121 /* So things look consistent in everyone's emacs... */ 00122 /* Local Variables: */ 00123 /* indent-tabs-mode: nil */ 00124 /* End: */