MiddleTemporal.H

00001 /*!@file Robots2/Beobot2/Navigation/FOE_Navigation/MiddleTemporal.H */
00002 // //////////////////////////////////////////////////////////////////// //
00003 // The iLab Neuromorphic Vision C++ Toolkit - Copyright (C) 2001 by the //
00004 // University of Southern California (USC) and the iLab at USC.         //
00005 // See http://iLab.usc.edu for information about this project.          //
00006 // //////////////////////////////////////////////////////////////////// //
00007 // Major portions of the iLab Neuromorphic Vision Toolkit are protected //
00008 // under the U.S. patent ``Computation of Intrinsic Perceptual Saliency //
00009 // in Visual Environments, and Applications'' by Christof Koch and      //
00010 // Laurent Itti, California Institute of Technology, 2001 (patent       //
00011 // pending; application number 09/912,225 filed July 23, 2001; see      //
00012 // http://pair.uspto.gov/cgi-bin/final/home.pl for current status).     //
00013 // //////////////////////////////////////////////////////////////////// //
00014 // This file is part of the iLab Neuromorphic Vision C++ Toolkit.       //
00015 //                                                                      //
00016 // The iLab Neuromorphic Vision C++ Toolkit is free software; you can   //
00017 // redistribute it and/or modify it under the terms of the GNU General  //
00018 // Public License as published by the Free Software Foundation; either  //
00019 // version 2 of the License, or (at your option) any later version.     //
00020 //                                                                      //
00021 // The iLab Neuromorphic Vision C++ Toolkit is distributed in the hope  //
00022 // that it will be useful, but WITHOUT ANY WARRANTY; without even the   //
00023 // implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR      //
00024 // PURPOSE.  See the GNU General Public License for more details.       //
00025 //                                                                      //
00026 // You should have received a copy of the GNU General Public License    //
00027 // along with the iLab Neuromorphic Vision C++ Toolkit; if not, write   //
00028 // to the Free Software Foundation, Inc., 59 Temple Place, Suite 330,   //
00029 // Boston, MA 02111-1307 USA.                                           //
00030 // //////////////////////////////////////////////////////////////////// //
00031 //
00032 // Primary maintainer for this file: Christian Siagian <siagian@usc.edu>
00033 // $HeadURL: svn://ilab.usc.edu/trunk/saliency/src/Robots/Beobot2/Navigation/FOE_Navigation/MiddleTemporal.H
00034 // $ $Id: $
00035 //
00036 //////////////////////////////////////////////////////////////////////////
00037 
00038 #include "Image/Image.H"
00039 #include "Image/Layout.H"
00040 #include "Raster/Raster.H"
00041 
00042 #include "Image/PyramidOps.H"
00043 #include "Image/ImageSet.H"
00044 #include "Image/DrawOps.H"
00045 #include "Image/PyramidTypes.H"
00046 #include "Image/PyrBuilder.H"
00047 #include "Image/MathOps.H"
00048 #include "GUI/XWinManaged.H"
00049 
00050 #ifndef MIDDLETEMPORAL_H
00051 #define MIDDLETEMPORAL_H
00052 
00053 #define MAX_NEIGHBORHOOD       4
00054 
00055 
00056 class MiddleTemporal
00057 {
00058 public:
00059 
00060   MiddleTemporal();
00061 
00062   void reset(uint numPyrLevel, uint numDirs, uint numSpeeds);
00063 
00064   ~MiddleTemporal();
00065 
00066   //! returns the MT feature overlay on the input image
00067   //! for display purposes 
00068   Layout<byte> getMTfeaturesDisplay(Image<byte> image);
00069 
00070   //! compute the Medial Temporal motion features
00071   void computeMTfeatures
00072   (std::vector<std::vector<ImageSet<float> > > itsRawSpatioTemporalEnergy);
00073 
00074   std::vector<Image<float> > getMTfeatures();
00075   std::vector<Image<float> > getMToptimalShift();
00076 
00077 private:
00078 
00079   //! just to reset the sizes of the maps
00080   void reset();
00081 
00082   //! find the optimal speeds for each direction
00083   void         computeMaxSpeed(uint index);
00084   Image<float> computeMaxSpeed(uint index, int scale);
00085 
00086   //! compute the max values of each location
00087   void computeSteMaxVals();
00088   void computeDirSteMaxVals();
00089 
00090   //! normalize the motion detection values to 1.0
00091   void normalizeOnMaxVal();
00092 
00093   //! compute the ooponency values
00094   void computeOpponencies();
00095 
00096   //! center surround lateral inhibition for each direction
00097   Image<float> getOnSpotInhibitSpatioTemporalEnergy(uint dir, uint scale);
00098 
00099   //! lateral inhibition for each direction
00100   //! from original location 
00101   Image<float> getNeighborInhibitSpatioTemporalEnergy(uint dir, uint scale);
00102 
00103   //! we weigh MT features for dominance to particular direction
00104   void weighMTfeaturesForDominance();
00105 
00106   //! final calculations to compute MT features
00107   void findMaxMotionVals();
00108 
00109   //! printing procedures
00110   void printItsSpatioTemporalEnergy
00111   (uint si, uint ei, uint sj, uint ej, bool stop = false, float div = 1.0);
00112   void displayItsSpatioTemporalEnergy();
00113   void printItsMTfeatures(uint si, uint ei, uint sj, uint ej, bool stop);
00114   void printItsMToptimalShift(uint si, uint ei, uint sj, uint ej, bool stop);
00115   void displayItsMTfeatures();
00116   void displayItsMToptimalShift();
00117 
00118   uint  itsNumPyrLevels;
00119   uint  itsNumDirs;
00120   uint  itsNumSpeeds;
00121 
00122 
00123   //! max values within a neighborhood
00124   //! for all directions
00125   ImageSet<float> itsSteMaxVals;
00126   //! max values within a neighborhood
00127   //! for each direction
00128   std::vector<ImageSet<float> > itsDirSteMaxVals;
00129 
00130   //! raw motion energy for each direction
00131   std::vector<std::vector<ImageSet<float> > > itsRawSpatioTemporalEnergy;
00132   std::vector<ImageSet<float> > itsSpatioTemporalEnergy;
00133   std::vector<ImageSet<float> > itsSpatioTemporalEnergyOptimalShift;
00134 
00135   //! filtered: collapsed to the number of directions 
00136   //! this already includes:
00137   //!   lateral inhibition
00138   //!   center surround opponencies
00139   std::vector <Image<float> > itsMTfeatures;
00140   std::vector <Image<float> > itsMToptimalShift;
00141 
00142   rutz::shared_ptr<XWinManaged> itsWin;
00143 };
00144 #endif
00145 
00146 // ######################################################################
00147 /* So things look consistent in everyone's emacs... */
00148 /* Local Variables: */
00149 /* indent-tabs-mode: nil */
00150 /* End: */
Generated on Sun May 8 08:41:18 2011 for iLab Neuromorphic Vision Toolkit by  doxygen 1.6.3