00001 /*!@file Channels/SoxChannel.H Shortrange Orientation Interactions channel */ 00002 00003 // //////////////////////////////////////////////////////////////////// // 00004 // The iLab Neuromorphic Vision C++ Toolkit - Copyright (C) 2001 by the // 00005 // 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@klab.caltech.edu> 00034 // $HeadURL: svn://isvn.usc.edu/software/invt/trunk/saliency/src/Channels/SoxChannel.H $ 00035 // $Id: SoxChannel.H 8831 2007-10-12 23:13:54Z rjpeters $ 00036 // 00037 00038 #ifndef SOXCHANNEL_H_DEFINED 00039 #define SOXCHANNEL_H_DEFINED 00040 00041 #include "Channels/ComplexChannel.H" 00042 #include "Channels/GaborChannel.H" 00043 #include <vector> 00044 00045 //! A short-range orientation interactions channel. 00046 /*! This class implements a pool of orientation-tuned units whose responses 00047 are shaped by divisive inhibition in proportion to population activity. */ 00048 class SoxChannel : public ComplexChannel 00049 { 00050 public: 00051 //! Construct 00052 SoxChannel(OptionManager& mgr); 00053 00054 //! Virtual destructor. 00055 virtual ~SoxChannel(); 00056 00057 //! Get the number of scales used. 00058 uint numScales() const; 00059 00060 //! Get the linear response of the units for a given orientation+scale. 00061 Image<float> getLinearResponse(int ori, int scl); 00062 00063 //! Get the non-linear response of the units for a given orientation+scale. 00064 /*! This is (rougly speaking) given by a power of the linear response, 00065 divided by an inhibitory term that pools over all orientations and 00066 scales. */ 00067 Image<float> getNonlinearResponse(int ori, int scl); 00068 00069 //! Wraps ComplexChannel's subChan() and casts the result to GaborChannel. 00070 nub::ref<GaborChannel> gabor(const uint idx) const; 00071 00072 protected: 00073 OModelParam<uint> itsNumOrients; //!< number of Gabor subchannels 00074 OModelParam<double> thetaPoolWidth; 00075 OModelParam<double> omegaPoolWidth; 00076 OModelParam<double> inhibExponent; 00077 OModelParam<double> excitExponent; 00078 OModelParam<double> semiSaturation; 00079 OModelParam<double> cutoff; 00080 00081 //! (re-)build our subchannels 00082 void buildSubChans(); 00083 00084 //! SoxChannel requires only luminance input. 00085 virtual void doInput(const InputFrame& inframe); 00086 00087 //! Combine all of the nonlinear responses. 00088 virtual Image<float> combineOutputs(); 00089 00090 //! Clear our cached inhibitory pool maps. 00091 virtual void killCaches(); 00092 00093 //! Overload so that we can reconfigure when our params get changed 00094 virtual void paramChanged(ModelParamBase* const param, 00095 const bool valueChanged, 00096 ParamClient::ChangeStatus* status); 00097 00098 private: 00099 // a private struct for caching stuff: 00100 struct CacheElem 00101 { 00102 CacheElem() : img(), ori(-1), scl(-1), exc_scl(-1) 00103 {} 00104 00105 CacheElem(const Image<float>& i, int o, int s, int e) : 00106 img(i), ori(o), scl(s), exc_scl(e) 00107 {} 00108 00109 Image<float> img; 00110 int ori; 00111 int scl; 00112 int exc_scl; 00113 }; 00114 00115 typedef std::vector<CacheElem> Cache; 00116 std::vector<Cache> inhibCaches; 00117 00118 Image<float> getInhib(int ori, int scl, int exc_scl, const Dims& dims, 00119 const Image<float>& linearResponse); 00120 }; 00121 00122 // ###################################################################### 00123 /* So things look consistent in everyone's emacs... */ 00124 /* Local Variables: */ 00125 /* indent-tabs-mode: nil */ 00126 /* End: */ 00127 00128 #endif // !SOXCHANNEL_H_DEFINED