SpaceVariantModule.H

Go to the documentation of this file.
00001 /*!@file SpaceVariant/SpaceVariantModule.H a model component that embodies different
00002     space variant image transforms (e.g. foveation). */
00003 
00004 // //////////////////////////////////////////////////////////////////// //
00005 // The iLab Neuromorphic Vision C++ Toolkit - Copyright (C) 2000-2003   //
00006 // by the University of Southern California (USC) and the iLab at USC.  //
00007 // See http://iLab.usc.edu for information about this project.          //
00008 // //////////////////////////////////////////////////////////////////// //
00009 // Major portions of the iLab Neuromorphic Vision Toolkit are protected //
00010 // under the U.S. patent ``Computation of Intrinsic Perceptual Saliency //
00011 // in Visual Environments, and Applications'' by Christof Koch and      //
00012 // Laurent Itti, California Institute of Technology, 2001 (patent       //
00013 // pending; application number 09/912,225 filed July 23, 2001; see      //
00014 // http://pair.uspto.gov/cgi-bin/final/home.pl for current status).     //
00015 // //////////////////////////////////////////////////////////////////// //
00016 // This file is part of the iLab Neuromorphic Vision C++ Toolkit.       //
00017 //                                                                      //
00018 // The iLab Neuromorphic Vision C++ Toolkit is free software; you can   //
00019 // redistribute it and/or modify it under the terms of the GNU General  //
00020 // Public License as published by the Free Software Foundation; either  //
00021 // version 2 of the License, or (at your option) any later version.     //
00022 //                                                                      //
00023 // The iLab Neuromorphic Vision C++ Toolkit is distributed in the hope  //
00024 // that it will be useful, but WITHOUT ANY WARRANTY; without even the   //
00025 // implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR      //
00026 // PURPOSE.  See the GNU General Public License for more details.       //
00027 //                                                                      //
00028 // You should have received a copy of the GNU General Public License    //
00029 // along with the iLab Neuromorphic Vision C++ Toolkit; if not, write   //
00030 // to the Free Software Foundation, Inc., 59 Temple Place, Suite 330,   //
00031 // Boston, MA 02111-1307 USA.                                           //
00032 // //////////////////////////////////////////////////////////////////// //
00033 //
00034 // Primary maintainer for this file: David J. Berg <dberg@usc.edu>
00035 // $HeadURL: svn://isvn.usc.edu:/software/invt/trunk/saliency/src/SpaceVariant/SpaceVariantModule.H $
00036 
00037 #ifndef SPACEVARIANTMODULE_H_DEFINED
00038 #define SPACEVARIANTMODULE_H_DEFINED
00039 
00040 
00041 #include "Component/ModelComponent.H"
00042 #include "Component/ModelParam.H"
00043 #include "SpaceVariant/SpaceVariantTransforms.H"
00044 #include "Image/Pixels.H"
00045 #include "Image/LevelSpec.H"
00046 
00047 class SVChanLevels;
00048 class ModelManager;
00049 // ###################################################################### 
00050 // a Model Component that embodies a space variant transform. Derive 
00051 // from this class and implement clear() to create your own transform.
00052 // See Image/SpaceVariantTransforms.H for details on the computation. 
00053 // The tempalte parameter should be the type of space variant transform
00054 // the user desires. 
00055 // ######################################################################
00056 class SpaceVariantModule : public ModelComponent
00057 {
00058 public:
00059   //! Constructor
00060   /*! See ModelComponent.H for details */
00061   SpaceVariantModule(OptionManager& mgr, const std::string& descrName = "SpaceVariantModule",
00062                      const std::string& tagName = "SpaceVariantModule");
00063 
00064   //! Destructor
00065   virtual ~SpaceVariantModule();
00066   
00067   //! reset transforms to the desired input image size
00068   virtual void clear(const Dims& inp_dims);
00069 
00070   //! clear the transforms
00071   void clear();
00072 
00073   /*!Here, for polymoprhism, we provide virtual functions for commonly used types. 
00074     However, for flexibility we also provide generic template functions. */
00075 
00076   //! transform a cartesian image to a space variant one
00077   virtual Image<PixRGB<float> > transformRbg(const Image<PixRGB<byte> >& image, const ImageSet<PixRGB<float> >* const pyr_cache = NULL);
00078   
00079   //! transform a cartesian image to a space variant pyramid
00080   virtual void transformRgbPyramid(const Image<PixRGB<byte> >& image, ImageSet<PixRGB<float> >& pyramid, const SVChanLevels& levels, const ImageSet<PixRGB<float> >* const pyr_cache);
00081   
00082   //! transform a cartesian image to a space variant one
00083   virtual Image<float> transformFloat(const Image<float>& image, const ImageSet<float>* const pyr_cache = NULL);
00084   
00085   //! transform a cartesian image to a space variant pyramid
00086   virtual void transformFloatPyramid(const Image<float>& image, ImageSet<float>& pyramid, const SVChanLevels& levels, const ImageSet<float>* const pyr_cache);
00087   
00088   //!Compute just the scale space sometimes we may want to just get the scale space
00089   template <class T_or_RGB>
00090   ImageSet<T_or_RGB> getScaleSpace(const Image<T_or_RGB>& inp, const float& maxrf = -1.0F);
00091   
00092   //! transform a cartesian image to a space variant one
00093   template <class T_or_RGB>
00094   Image<T_or_RGB> transform(const Image<T_or_RGB>& image, const ImageSet<typename promote_trait<T_or_RGB, float>::TP>* const pyr_cache = NULL);
00095 
00096   //! transform a cartesian image to a space variant pyramid
00097   template <class T_or_RGB>
00098   void transformPyramid(const Image<T_or_RGB>& image, ImageSet<typename promote_trait<T_or_RGB, float>::TP>& pyramid, const SVChanLevels& levels, const ImageSet<typename promote_trait<T_or_RGB, float>::TP>* const pyr_cache = NULL);
00099   
00100   /*! transform a cartesian image to a space variant one, 
00101     but first center the image to the desired point. */
00102   template <class T_or_RGB>
00103   Image<T_or_RGB> transform(const Image<T_or_RGB>& image, const Point2D<int>& fovea, const ImageSet<typename promote_trait<T_or_RGB, float>::TP>* const pyr_cache = NULL);
00104 
00105   /*! transform a cartesian image to a space variant one, 
00106     but first center the image to the desired point and crop. */
00107   template <class T_or_RGB>
00108   Image<T_or_RGB> cropTransform(const Image<T_or_RGB>& image, const Point2D<int>& fovea, const Dims& dims, const ImageSet<typename promote_trait<T_or_RGB, float>::TP>* const pyr_cache = NULL);
00109   
00110   //! inverse transform an already space variant transformed image back to a cartesian one
00111   template <class T_or_RGB>
00112   Image<T_or_RGB> inverseTransform(const Image<T_or_RGB>& ret_image) const;
00113   
00114   /*! We may perform pyramid operations on space variant images and this function allows for images
00115     at the output map scale (see LevelSpec.H) to be inverse transformed back to the input image dimensions. */
00116   template <class T_or_RGB>
00117   Image<T_or_RGB> inverseMap(const Image<T_or_RGB>& map_image) const;
00118 
00119   //!transform a point from cartesian to space variant coords
00120   void toSvCoords(Point2D<int>& point) const;
00121 
00122   //!transform a point from space variant to cartesian coords
00123   void fromSvCoords(Point2D<int>& point) const;
00124 
00125   //!transform a point to space variant coords at the map level
00126   void toSvCoordsMap(Point2D<int>& point) const;
00127 
00128   //!transform a point from space variant coords at the map level
00129   void fromSvCoordsMap(Point2D<int>& point) const;
00130 
00131   //!returnt true if we have valid transforms
00132   bool validTransforms() const;
00133 
00134   //!return the transform
00135   rutz::shared_ptr<SpaceVariantTransform> getTransform();
00136 
00137   //!return the map level transform
00138   rutz::shared_ptr<SpaceVariantTransform> getMapTransform();
00139 
00140   //!set the transform
00141   void setTransform(rutz::shared_ptr<SpaceVariantTransform> transform);
00142   
00143   //!set the map level transform
00144   void setMapTransform(rutz::shared_ptr<SpaceVariantTransform> map_transform);
00145 
00146   //!get the max rf size in sigmas
00147   float getMaxRf() const;
00148 
00149   //!get the max rf size in sigmas given an offset and surround factor
00150   float getMaxRf(const float& offset, const float& surround_factor);
00151 
00152 protected:
00153   //reset our internals
00154   void reset1();
00155 
00156   //the transforms
00157   rutz::shared_ptr<SpaceVariantTransform> itsTransform;
00158   rutz::shared_ptr<SpaceVariantTransform> itsMapTransform;
00159 };
00160 
00161 #endif //SPACEVARIANTMODULE
00162 // ######################################################################
00163 /* So things look consistent in everyone's emacs... */
00164 /* Local Variables: */
00165 /* indent-tabs-mode: nil */
00166 /* End: */
Generated on Sun May 8 08:42:18 2011 for iLab Neuromorphic Vision Toolkit by  doxygen 1.6.3