Main Page | Modules | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Namespace Members | Class Members | File Members | Related Pages

EnvVisualCortex.H

Go to the documentation of this file.
00001 /*!@file Neuro/EnvVisualCortex.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/Neuro/EnvVisualCortex.H $
00035 // $Id: EnvVisualCortex.H 10989 2009-03-05 22:42:20Z itti $
00036 //
00037 
00038 #ifndef NEURO_ENVVISUALCORTEX_H_DEFINED
00039 #define NEURO_ENVVISUALCORTEX_H_DEFINED
00040 
00041 #include "Component/ModelComponent.H"
00042 #include "Component/ModelParam.H"
00043 #include "Envision/env_params.h"
00044 #include "Envision/env_types.h"
00045 #include "Envision/env_visual_cortex.h"
00046 #include "Image/Image.H"
00047 #include "Image/LevelSpec.H"
00048 #include "Image/Pixels.H"
00049 #include "rutz/shared_ptr.h"
00050 
00051 class WorkThreadServer;
00052 
00053 extern const ModelOptionDef OPT_EvcMaxnormType;
00054 extern const ModelOptionDef OPT_EvcScaleBits;
00055 #ifdef ENV_WITH_DYNAMIC_CHANNELS
00056 extern const ModelOptionDef OPT_EvcNumDirections;
00057 extern const ModelOptionDef OPT_EvcMotionThresh;
00058 extern const ModelOptionDef OPT_EvcFlickerThresh;
00059 extern const ModelOptionDef OPT_EvcMultiScaleFlicker;
00060 #endif
00061 extern const ModelOptionDef OPT_EvcNumOrientations;
00062 extern const ModelOptionDef OPT_EvcLevelSpec;
00063 extern const ModelOptionDef OPT_EvcType;
00064 extern const ModelOptionDef OPT_EvcColorSmoothing;
00065 extern const ModelOptionDef OPT_EvcOutputFactor;
00066 
00067 class EnvVisualCortex : public ModelComponent
00068 {
00069 public:
00070   EnvVisualCortex(OptionManager& mgr,
00071       const std::string& descrName = "EnvVisualCortex",
00072       const std::string& tagName = "EnvVisualCortex");
00073 
00074   virtual ~EnvVisualCortex();
00075 
00076   env_size_t getMapLevel() const { return this->envp.output_map_level; }
00077 
00078   void input(const Image<PixRGB<byte> >& rgbin);
00079 
00080   Image<byte> getVCXmap() const { return itsVCXmap; }
00081 
00082   Image<float> getVCXmapFloat() const {
00083     // here we convert to float and scale the values in one shot thanks
00084     // to the built-in automatic type promotions of Image::operator*():
00085     return itsVCXmap * itsOutputFactor.getVal();
00086   }
00087 
00088   Image<byte> getImap() const { return itsImap; }
00089   Image<byte> getCmap() const { return itsCmap; }
00090   Image<byte> getOmap() const { return itsOmap; }
00091   byte getIweight() { return envp.chan_i_weight; }
00092   byte getCweight() { return envp.chan_c_weight; }
00093   byte getOweight() { return envp.chan_o_weight; }
00094 #ifdef ENV_WITH_DYNAMIC_CHANNELS
00095   Image<byte> getFmap() const { return itsFmap; }
00096   Image<byte> getMmap() const { return itsMmap; }
00097   byte getFweight() { return envp.chan_f_weight; }
00098   byte getMweight() { return envp.chan_m_weight; }
00099 #endif
00100 
00101   const struct env_params& getParams() const { return envp; }
00102 
00103   bool getColorSmoothing() const { return itsColorSmoothing.getVal(); }
00104 
00105   void setIweight(byte val) { envp.chan_i_weight = val; }
00106   void setCweight(byte val) { envp.chan_c_weight = val; }
00107   void setOweight(byte val) { envp.chan_o_weight = val; }
00108 
00109   void setNumOrientations(byte val) { envp.num_orientations = val; }
00110 
00111 #ifdef ENV_WITH_DYNAMIC_CHANNELS
00112   void setFweight(byte val) { envp.chan_f_weight = val; }
00113   void setMweight(byte val) { envp.chan_m_weight = val; }
00114 
00115   void setFthresh(byte val) { envp.flicker_thresh = val; }
00116   void setMthresh(byte val) { envp.motion_thresh = val; }
00117 
00118   void setMultiScaleFlicker(bool val) { envp.multiscale_flicker = val ? 1 : 0; }
00119 
00120   void setNumDirections(byte val) { envp.num_motion_directions = val; }
00121 #endif
00122 
00123   void setColorSmoothing(bool val) { itsColorSmoothing.setVal(val); }
00124 
00125 #ifdef ENV_WITH_VISIT_CHANNEL
00126   void setSubmapPreProc(int (*submapPreProc)(const char* tagName,
00127             env_size_t clev, env_size_t slev, struct env_image *submap,
00128             const struct env_image *center, const struct env_image *surround))
00129   { envp.submapPreProc = submapPreProc; }
00130 
00131   void setSubmapPostNormProc(int (*submapPostNormProc)(const char* tagName,
00132             env_size_t clev, env_size_t slev, struct env_image *submap,
00133             const struct env_image *center, const struct env_image *surround))
00134   { envp.submapPostNormProc = submapPostNormProc; }
00135   void setSubmapPostProc(int (*submapPostProc)(const char* tagName,
00136             struct env_image *cmap))
00137   { envp.submapPostProc = submapPostProc; }
00138 #endif
00139 
00140 private:
00141   virtual void paramChanged(ModelParamBase* const param,
00142                             const bool valueChanged,
00143                             ParamClient::ChangeStatus* status);
00144 
00145   virtual void start1();
00146 
00147   virtual void stop2();
00148 
00149 
00150   NModelParam<byte> itsIweight;
00151   NModelParam<byte> itsCweight;
00152   NModelParam<byte> itsOweight;
00153 #ifdef ENV_WITH_DYNAMIC_CHANNELS
00154   NModelParam<byte> itsFweight;
00155   NModelParam<byte> itsMweight;
00156 #endif
00157 
00158   OModelParam<bool> itsMultithreaded;
00159   OModelParam<std::string> itsMaxnormType;
00160   OModelParam<byte> itsScaleBits;
00161   OModelParam<byte> itsNumOrientations;
00162   OModelParam<bool> itsColorSmoothing;
00163 #ifdef ENV_WITH_DYNAMIC_CHANNELS
00164   OModelParam<byte> itsNumDirections;
00165   OModelParam<byte> itsMotionThresh;
00166   OModelParam<byte> itsFlickerThresh;
00167   OModelParam<int> itsRangeThresh;
00168   OModelParam<bool> itsMultiScaleFlicker;
00169 #endif
00170   OModelParam<LevelSpec> itsLevelSpec;
00171 
00172   OModelParam<std::string> itsType;
00173   OModelParam<float> itsOutputFactor;   //!< output range factor
00174 
00175   struct env_params envp;
00176   struct env_visual_cortex ivc;
00177 
00178   env_size_t npixels;
00179 
00180   int framenum;
00181 
00182   intg32 chanmi, chanma;
00183   intg32 vcxmi, vcxma;
00184 
00185   Image<byte> itsVCXmap;
00186 
00187   Image<byte> itsImap;
00188   Image<byte> itsCmap;
00189   Image<byte> itsOmap;
00190 #ifdef ENV_WITH_DYNAMIC_CHANNELS
00191   Image<byte> itsFmap;
00192   Image<byte> itsMmap;
00193 #endif
00194 
00195   Image<PixRGB<byte> > itsPrevRgb;
00196 
00197   rutz::shared_ptr<WorkThreadServer> itsThreadServer;
00198 };
00199 
00200 // ######################################################################
00201 /* So things look consistent in everyone's emacs... */
00202 /* Local Variables: */
00203 /* mode: c++ */
00204 /* indent-tabs-mode: nil */
00205 /* End: */
00206 
00207 #endif // NEURO_ENVVISUALCORTEX_H_DEFINED

Generated on Sun Nov 22 13:42:42 2009 for iLab Neuromorphic Vision Toolkit by  doxygen 1.4.4