Hmax.H

Go to the documentation of this file.
00001 /*!@file HMAX/Hmax.H Riesenhuber & Poggio's HMAX model for object recognition */
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: Laurent Itti <itti@usc.edu>
00034 // $HeadURL: svn://isvn.usc.edu/software/invt/trunk/saliency/src/HMAX/Hmax.H $
00035 // $Id: Hmax.H 14139 2010-10-16 02:11:21Z dparks $
00036 //
00037 
00038 #ifndef HMAX_H_DEFINED
00039 #define HMAX_H_DEFINED
00040 
00041 #include "Image/Image.H"
00042 #include <vector>
00043 
00044 #include <cmath>
00045 #include <string>
00046 #include <vector>
00047 #include <dirent.h>
00048 
00049 //! Object recognition model inspired from Riesenhuber & Poggio's HMAX model
00050 /*! See Riesenhuber & Poggio, Nature Neuroscience, 1999.
00051  */
00052 
00053 class Hmax {
00054 public:
00055   //! Default constructor. Need to call init() later.
00056   Hmax();
00057 
00058   //! Constructor
00059   Hmax(const int nori, const std::vector<int>& spacess,
00060        const std::vector<int>& scaless, const int c1spaceol = 2,
00061        const bool angleflag = true, const float s2t = 1.0F,
00062        const float s2s = 1.0F, const float stdmin = 1.75F,
00063        const float stdstep = 0.5F, const int fsmin = 3, const int fsstep = 1);
00064 
00065   //! Initialization
00066   void init(const int nori, const std::vector<int>& spacess,
00067             const std::vector<int>& scaless, const int c1spaceol = 2,
00068             const bool angleflag = true, const float s2t = 1.0F,
00069             const float s2s = 1.0F);
00070 
00071   void initFilters(const float stdmin, const float stdstep, const int fsmin, const int fsstep);
00072 
00073 
00074   //! Free internal memory
00075   void freeMem();
00076 
00077   //! Destructor
00078   ~Hmax();
00079 
00080   //! For utilize the operation : read a directory and pass the list of files
00081   std::vector<std::string> readDir(std::string dirName);
00082   std::vector<std::string> readList(std::string inName);
00083   //! This is the code of Max Riesenhuber almost straight out of the box
00084   Image<float> origGetC2(const Image<float>& imag);
00085 
00086   //! Compute C2 responses from an input image
00087   Image<float> getC2(const Image<float>& input);
00088   int getNumOrientations();
00089   void initC1(Image<float> **&c1Res);
00090   void clearC1(Image<float> **&c1Res);
00091   void printCorners(const char name[], const Image<float>& im, bool cond);
00092   void writeOutImage(const Image<float>& im,std::string & fName);
00093   // Calculate just the C1 level (must be public if you need to learn patches)
00094   void getC1(const Image<float>& input, Image<float>**& c1Res);
00095   void sumFilter(const Image<float>& image, const float radius, Image<float>& newImage);
00096   void sumFilter(const Image<float>& image, const Rectangle& support, Image<float>& newImage);
00097 
00098 protected:
00099   bool initialized; //!< keep track of whether we have allocated some memory
00100   int nsb; //!< number of scale bands
00101   int ns;  //!< number of scales
00102   int no;  //!< number of orientations
00103   Image<float> **filter; //!< low-level processing filters [ns][no]
00104 
00105   int c1SpaceOL;  //!< spatial overlap in C1 cells
00106   bool angleFlag; //!< normalize convolution by image energy if true
00107   float s2Target; //!< center of S2 target
00108   float s2Sigma;  //!< size of S2 target
00109 
00110   std::vector<int> spaceSS;
00111   std::vector<int> scaleSS;
00112 };
00113 
00114 #endif
00115 
00116 // ######################################################################
00117 /* So things look consistent in everyone's emacs... */
00118 /* Local Variables: */
00119 /* indent-tabs-mode: nil */
00120 /* End: */
Generated on Sun May 8 08:04:48 2011 for iLab Neuromorphic Vision Toolkit by  doxygen 1.6.3