ShapeEstimator.H

Go to the documentation of this file.
00001 /*!@file Neuro/ShapeEstimator.H Estimate the shape/size of an attended object */
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: Dirk Walther <walther>
00034 // $HeadURL: svn://isvn.usc.edu/software/invt/trunk/saliency/src/Neuro/ShapeEstimator.H $
00035 // $Id: ShapeEstimator.H 14762 2011-05-03 01:13:16Z siagian $
00036 //
00037 
00038 #ifndef SHAPEESTIMATOR_H_DEFINED
00039 #define SHAPEESTIMATOR_H_DEFINED
00040 
00041 #include "Component/ModelComponent.H"
00042 #include "Component/ModelParam.H"
00043 #include "Simulation/SimModule.H"
00044 #include "Image/Image.H"
00045 #include "Neuro/NeuroSimEvents.H"
00046 #include "Neuro/ShapeEstimatorModes.H"
00047 #include "Simulation/SimEvents.H"
00048 #include <string>
00049 #include "Image/NamedImage.H"
00050 
00051 #include "Gist/SalientRegionSegmenter.H" 
00052 
00053 #include "GUI/XWinManaged.H"
00054 
00055 class VisualCortex;
00056 class SpatialMetrics;
00057 
00058 //! everything related to the shape estimation procedure
00059 /*! class to take care of all things related to the shape estimation
00060   procedure published in Walther et al, BMCV 02 */
00061 class ShapeEstimator : public SimModule
00062 {
00063 public:
00064 
00065   //! Constructor
00066   /*! @param vcx this is the hook for the class to obtain its information
00067     on channels, submaps etc. */
00068   ShapeEstimator(OptionManager& mgr,
00069                  const std::string& descrName = "Shape Estimator",
00070                  const std::string& tagName = "shapeestimator",
00071                  const nub::soft_ref<VisualCortex> vcx =
00072                  nub::soft_ref<VisualCortex>());
00073 
00074 protected:
00075   //! Callback for when a new WTA winner is available
00076   SIMCALLBACK_DECLARE(ShapeEstimator, SimEventWTAwinner);
00077 
00078   //! Callback for every time we should save our outputs
00079   SIMCALLBACK_DECLARE(ShapeEstimator, SimEventSaveOutput);
00080 
00081   //!< metrics that depend on the input size:
00082   nub::ref<SpatialMetrics> itsMetrics;
00083 
00084   //! Text log file name
00085   OModelParam<std::string> itsLogFile;
00086 
00087   //! Determines what information is used as a source for the shape estimation
00088   /*! possible values:<ul><li>"None" - shape estimator is not used;
00089     <li>"FeatureMap" - the shape is extracted from the winning Feature Map;
00090     <li>"ConspicuityMap" - shape is extracted from the winning Conspicuity Map;
00091     <li>"SaliencyMap" - the shape is extracted from the Saliency Map</ul>*/
00092   OModelParam<ShapeEstimatorMode> itsMode;
00093 
00094   //! Determines Smoothing Method used to extract a map in image coordinates
00095   /*! possible values:<ul>
00096     <li>"None" - no smoothing, the result is just scaled up in blocks;
00097     <li>"Gaussian" - smoothing by convolving with a large 2D Gaussian kernel;
00098     <li>"Chamfer" - smoothing with Opening and Chamfering (takes about half
00099     the time compared to "Gaussian"</ul>*/
00100   OModelParam<ShapeEstimatorSmoothMethod> itsSmMethod;
00101 
00102   //! Save our internals?
00103   OModelParam<bool> itsSaveObjMask;
00104 
00105   //! use a larger neighborhood when tracking down a local max?
00106   OModelParam<bool> itsUseLargeNeigh;
00107 
00108   //! Reset ShapeEstimator
00109   /*! See the base function in ModelComponent.H for info. */
00110   virtual void reset1();
00111 
00112 private:
00113   // Locate a local max in submap (any size smaller than input size)
00114   // around winner (given in coordinates of an image of dims indims)
00115   // and returns the matching coordinates in submap's resolution as
00116   // well as the value at the max.
00117   float locateLocalMax(const Image<float>& submap,
00118                        const Point2D<int>& winner,
00119                        const Dims& fulldims,
00120                        Point2D<int>& winloc,
00121                        int mini = -1, int maxi = 1);
00122 
00123   // the structuring element for eroding and dilating
00124   // for the chamfer smoothing method
00125   Image<byte> structEl;
00126 
00127   // keep a copy of our last smooth mask so we can save it
00128   Image<float> itsSmoothMask;
00129 
00130   // our cumulative smooth mask
00131   Image<float> itsCumMask;
00132 
00133   //! will segment the region 
00134   //! around the salient point properly
00135   rutz::shared_ptr<SalientRegionSegmenter> itsSalientRegionSegmenter;
00136 
00137 
00138   rutz::shared_ptr<XWinManaged> itsWin;
00139   void getShapeEstimatorMap
00140   (SimEventQueue& q, rutz::shared_ptr<SimEventWTAwinner>& e);
00141 
00142   void getMotionShapeEstimatorMap
00143   (SimEventQueue& q, rutz::shared_ptr<SimEventWTAwinner>& e);
00144 
00145   void postShapeEstimatorMask
00146   (NamedImage<float> winmap, Point2D<int> winloc, 
00147    Point2D<int> winner, Dims indims, SimEventQueue& q);
00148 };
00149 
00150 #endif
00151 
00152 
00153 // ######################################################################
00154 /* So things look consistent in everyone's emacs... */
00155 /* Local Variables: */
00156 /* indent-tabs-mode: nil */
00157 /* End: */
Generated on Sun May 8 08:05:25 2011 for iLab Neuromorphic Vision Toolkit by  doxygen 1.6.3