00001 /*!@file Surprise/SurpriseImage.H a 2D array of SurpriseModel objects */ 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/SurpriseImage.H $ 00035 // $Id: SurpriseImage.H 9983 2008-07-27 06:34:32Z mundhenk $ 00036 // 00037 00038 #ifndef SURPRISEIMAGE_H_DEFINED 00039 #define SURPRISEIMAGE_H_DEFINED 00040 00041 #include "Image/Image.H" 00042 #include "Surprise/SurpriseModel.H" 00043 00044 // ###################################################################### 00045 //! A 2D array of SurpriseModel objects 00046 /*! This class is derived fromImage and inherits all its 00047 functionality, and in addition provides batch access to several of 00048 the SurpriseModel functions. Although the template argument T could 00049 in principle be anything, it is required that it supports the 00050 SurpriseModel functions like update(), surprise(), etc */ 00051 template <class T> 00052 class SurpriseImage : public Image<T> 00053 { 00054 public: 00055 //! Uninitialized constructor 00056 SurpriseImage(); 00057 00058 //! Constructor for an empty SurpriseImage with uninitialized models 00059 SurpriseImage(const Dims& dims); 00060 00061 //! Constructor from given sample means and variances 00062 SurpriseImage(const double updfac, const Image<double>& sampleval, 00063 const Image<double>& samplevar); 00064 00065 //! Virtual destructor ensures proper destruction of derived classes 00066 virtual ~SurpriseImage(); 00067 00068 //! Reset all models to initial state 00069 virtual void reset(); 00070 00071 //! Init to given sample mean and variance 00072 virtual void init(const double updfac, const Image<double>& sampleval, 00073 const Image<double>& samplevar); 00074 00075 //! reset our update factor 00076 virtual void resetUpdFac(const double updfac); 00077 00078 //! Compute surprise between us and another model 00079 virtual Image<double> surprise(const SurpriseImage<T>& other); 00080 00081 //! For models with covariance, pre-compute hyper parameters 00082 virtual void preComputeHyperParams(const SurpriseImage<T>& models); 00083 00084 //! Initialize us as a weighted combination of the given map of models 00085 /*! This will initialize us so that each of our pixels is built from 00086 the SurpriseModel combineFrom() function, with a Gaussian weighing 00087 mask centered onto that pixel and with sigma given here as 00088 argument. */ 00089 virtual void neighborhoods(const SurpriseImage<T>& models, 00090 const float neighsigma); 00091 00092 //! Initialize us as a weighted combination of the given map of models 00093 /*! This will initialize us so that each of our pixels is built from 00094 the SurpriseModel combineFrom() function. In this version, weights 00095 should be an image with double+1 the width and height of 00096 models. */ 00097 virtual void neighborhoods(const SurpriseImage<T>& models, 00098 const Image<float>& weights); 00099 00100 //! Call this to re-use the model and not initialize the model with a new one 00101 /*! This is a variant to use neighborhoods without needing to copy in a new 00102 model but insted preserves the current model params 00103 */ 00104 virtual void neighborhoods(const SurpriseImage<T>& models, 00105 const Image<float>& weights, 00106 const bool NO_INIT); 00107 //! get our means 00108 virtual Image<double> getMean() const; 00109 00110 //! get our variances 00111 virtual Image<double> getVar() const; 00112 }; 00113 00114 #endif 00115 00116 // ###################################################################### 00117 /* So things look consistent in everyone's emacs... */ 00118 /* Local Variables: */ 00119 /* indent-tabs-mode: nil */ 00120 /* End: */