IntegerRawVisualCortex.H

Go to the documentation of this file.
00001 /*!@file Channels/IntegerRawVisualCortex.H */
00002 
00003 // //////////////////////////////////////////////////////////////////// //
00004 // The iLab Neuromorphic Vision C++ Toolkit - Copyright (C) 2000-2005   //
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: Rob Peters <rjpeters at usc dot edu>
00034 // $HeadURL: svn://isvn.usc.edu/software/invt/trunk/saliency/src/Channels/IntegerRawVisualCortex.H $
00035 // $Id: IntegerRawVisualCortex.H 13993 2010-09-20 04:54:23Z itti $
00036 //
00037 
00038 #ifndef CHANNELS_INTEGERRAWVISUALCORTEX_H_DEFINED
00039 #define CHANNELS_INTEGERRAWVISUALCORTEX_H_DEFINED
00040 
00041 #include "Component/ModelComponent.H"
00042 #include "Component/ModelParam.H"
00043 #include "Image/Image.H"
00044 #include "Image/LevelSpec.H"
00045 #include "Image/fancynorm.H" // for MaxNormType
00046 #include "Util/Types.H"
00047 #include "rutz/shared_ptr.h"
00048 #include "Channels/ChannelOpts.H"
00049 #include "Channels/IntegerComplexChannel.H"
00050 #include "Channels/InputFrame.H"
00051 
00052 #include <string>
00053 #include <utility>
00054 #include <vector>
00055 
00056 // Forward declarations will suffice instead of #include's here, and
00057 // will be more efficient in compile times and in minimizing
00058 // dependencies.
00059 class FrameOstream;
00060 class InputFrame; // see Channels/InputFrame.H
00061 class ParamMap;
00062 class Retina;
00063 class SimTime;
00064 class WTAwinner;
00065 template <class T> class Jet;
00066 namespace rutz { template <class T> class shared_ptr; }
00067 template <class T> class PixRGB;
00068 class MgzDecoder;
00069 class MgzEncoder;
00070 
00071 // ######################################################################
00072 //! The Visual Cortex Class
00073 /*! In brief, IntegerRawVisualCortex holds a collection of IntegerChannel
00074     objects, and most of IntegerRawVisualCortex's operations are achieved
00075     by some kind of iteration over that collection. That is,
00076     IntegerRawVisualCortex now does little work by itself, but delegates
00077     its operations to the channels, accumulating their results if
00078     necessary. */
00079 class IntegerRawVisualCortex : public IntegerComplexChannel
00080 {
00081 public:
00082   // ######################################################################
00083   /*! @name Constructors/Destructor */
00084   //@{
00085 
00086   //! Construct with no channel; channels must then be added with addSubChan().
00087   /*! @param mgr our ModelManager (see ModelManager.H)
00088       @param descrName descriptive name for human usage
00089       @param tagName name for ParamMap usage */
00090   IntegerRawVisualCortex(OptionManager& mgr,
00091                       nub::ref<IntegerMathEngine> eng,
00092                       const std::string& descrName = "Integer Visual Cortex",
00093                       const std::string& tagName = "IntegerRawVisualCortex");
00094 
00095   //! Virtual destructor for safe inheritance.
00096   virtual ~IntegerRawVisualCortex();
00097 
00098   //@}
00099 
00100   //! Overload to not only convert to float but also apply our output factor
00101   virtual Image<float> getOutput();
00102 
00103   //! Save our results
00104   virtual void saveResults(const nub::ref<FrameOstream>& ofs);
00105 
00106 protected:
00107   virtual void doInputInt(const IntegerInput& inp,
00108                           const SimTime& t,
00109                           PyramidCache<int>* cache,
00110                           const Image<byte>& clipMask);
00111 
00112   //! Combine the outputs of our subchannels
00113   /*! We do this in a slightly different way than the ComplexChannel
00114       base version. */
00115   virtual Image<int> combineOutputsInt();
00116 
00117   //! get weighted (but not resized) channel output map
00118   virtual Image<int> getChannelOutputMap(IntegerChannel& chan) const;
00119 
00120   //! post-process raw weighted sum of channel output maps
00121   /*! Derived classes may overload this to provide custom
00122     post-processing. For example, IntegerRawVisualCortexSurprise may pass the
00123     output through a sigmoidal nonlinearity or spatial
00124     competition. Default implementation is to treat the special case
00125     of VCXNORM_LANDMARK. */
00126   virtual Image<int> postProcessOutputMap(const Image<int>& outmap);
00127 
00128   virtual void paramChanged(ModelParamBase* const param,
00129                             const bool valueChanged,
00130                             ParamClient::ChangeStatus* status);
00131 
00132   OModelParam<std::string> itsType;
00133   OModelParam<std::string> itsLogFile;  //!< text log file name
00134   OModelParam<MaxNormType> itsNormType; //!< maxNormalization to use
00135   OModelParam<bool> itsUseRandom;       //!< add random noise to output
00136   OModelParam<float> itsOutputFactor;   //!< output range factor
00137 
00138   /* older version: raw CS submaps -> [normalize, spatial competition,
00139      sum] -> SO -> [spatial competition, sum] -> CO -> [sum, spatial
00140      competition] -> VCX o/p :
00141 
00142      Since different feature types may have different range of
00143      responses, their responses are normalized to a fixed range so as
00144      to treat them equally. Ideally, normalization should occur at the
00145      visualCortex when it combines the outputs of the different
00146      feature types. Instead, the older version performs the
00147      normalization within each feature type, forcing all scales within
00148      a feature type to be treated as equally important. This is
00149      undesirable as it artificially magnifies even those scales which
00150      contain only noise, and we lose information about the relative
00151      goodness of the different scales.
00152 
00153      new version: raw CS submaps -> [spatial competition, sum] -> SO
00154      -> [spatial competition, sum] -> CO -> [normalize, sum, spatial
00155      competition] -> VCX o/p */
00156   OModelParam<bool> itsUseOlderVersion;
00157 
00158   //! LevelSpec used by our channels, used to compute output dims
00159   OModelParam<LevelSpec> itsLevelSpec;
00160   OModelParam<bool> itsSaveOutput;      //!< save our output?
00161   OModelParam<bool> itsUseMax;     //!< use max across features instead of sum?
00162 
00163   //! start
00164   virtual void start1();
00165 
00166   //! stop
00167   virtual void stop2();
00168 
00169 private:
00170   IntegerRawVisualCortex(const IntegerRawVisualCortex&); // not allowed
00171   IntegerRawVisualCortex& operator=(const IntegerRawVisualCortex&); // not allowed
00172 };
00173 
00174 // ######################################################################
00175 /* So things look consistent in everyone's emacs... */
00176 /* Local Variables: */
00177 /* mode: c++ */
00178 /* indent-tabs-mode: nil */
00179 /* End: */
00180 
00181 #endif // CHANNELS_INTEGERRAWVISUALCORTEX_H_DEFINED
Generated on Sun May 8 08:40:21 2011 for iLab Neuromorphic Vision Toolkit by  doxygen 1.6.3