HOG.H

Go to the documentation of this file.
00001 /*!@file Features/HOG.H  Histogram Of Gradients */
00002 //Code derived from http://www.cs.uchicago.edu/~pff/latent/
00003 //author = "Felzenszwalb, P. F. and Girshick, R. B. and McAllester, D.",
00004 //title = "Discriminatively Trained Deformable Part Models, Release 4",
00005 //howpublished = "http://people.cs.uchicago.edu/~pff/latent-release4/"}
00006 
00007 // //////////////////////////////////////////////////////////////////// //
00008 // The iLab Neuromorphic Vision C++ Toolkit - Copyright (C) 2000-2005   //
00009 // by the University of Southern California (USC) and the iLab at USC.  //
00010 // See http://iLab.usc.edu for information about this project.          //
00011 // //////////////////////////////////////////////////////////////////// //
00012 // Major portions of the iLab Neuromorphic Vision Toolkit are protected //
00013 // under the U.S. patent ``Computation of Intrinsic Perceptual Saliency //
00014 // in Visual Environments, and Applications'' by Christof Koch and      //
00015 // Laurent Itti, California Institute of Technology, 2001 (patent       //
00016 // pending; application number 09/912,225 filed July 23, 2001; see      //
00017 // http://pair.uspto.gov/cgi-bin/final/home.pl for current status).     //
00018 // //////////////////////////////////////////////////////////////////// //
00019 // This file is part of the iLab Neuromorphic Vision C++ Toolkit.       //
00020 //                                                                      //
00021 // The iLab Neuromorphic Vision C++ Toolkit is free software; you can   //
00022 // redistribute it and/or modify it under the terms of the GNU General  //
00023 // Public License as published by the Free Software Foundation; either  //
00024 // version 2 of the License, or (at your option) any later version.     //
00025 //                                                                      //
00026 // The iLab Neuromorphic Vision C++ Toolkit is distributed in the hope  //
00027 // that it will be useful, but WITHOUT ANY WARRANTY; without even the   //
00028 // implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR      //
00029 // PURPOSE.  See the GNU General Public License for more details.       //
00030 //                                                                      //
00031 // You should have received a copy of the GNU General Public License    //
00032 // along with the iLab Neuromorphic Vision C++ Toolkit; if not, write   //
00033 // to the Free Software Foundation, Inc., 59 Temple Place, Suite 330,   //
00034 // Boston, MA 02111-1307 USA.                                           //
00035 // //////////////////////////////////////////////////////////////////// //
00036 //
00037 // Primary maintainer for this file: Lior Elazary
00038 // $HeadURL$
00039 // $Id$
00040 //
00041 
00042 #ifndef HOG_H_DEFINED
00043 #define HOG_H_DEFINED
00044 
00045 #include "Util/Types.H"
00046 #include "Image/Image.H"
00047 #include "Image/Pixels.H"
00048 #include "Image/ImageSet.H"
00049 
00050 #include <vector>
00051 #include <string>
00052 
00053 //TODO: clean this up, and support more ori
00054 // unit vectors used to compute gradient orientation
00055 const double itsUU[9] = {1.0000, 
00056   0.9397, 
00057   0.7660, 
00058   0.500, 
00059   0.1736, 
00060   -0.1736, 
00061   -0.5000, 
00062   -0.7660, 
00063   -0.9397};
00064 const double itsVV[9] = {0.0000, 
00065   0.3420, 
00066   0.6428, 
00067   0.8660, 
00068   0.9848, 
00069   0.9848, 
00070   0.8660, 
00071   0.6428, 
00072   0.3420};
00073 
00074 class HOG
00075 {
00076   
00077 public:
00078   //! Constructor
00079   HOG();
00080 
00081   //! Destructor
00082   virtual ~HOG();
00083 
00084   //! Compute HOG features on an RGB image
00085   ImageSet<float> getFeatures(const Image<PixRGB<byte> >& img, int numBins);
00086 
00087   //! Compute the gradient on a color img by taking the max gradient
00088   //! If numOrientations > 0 then snap to the best orientation
00089   void getMaxGradient(const Image<PixRGB<byte> >& img,
00090       Image<float>& mag, Image<float>& ori,
00091       int numOrientations = -1);
00092 
00093   ImageSet<float> getOriHistogram(const Image<float>& mag,
00094       const Image<float>& ori, int numOrientations, int numBins);
00095 
00096  
00097   ImageSet<double> computeFeatures(const ImageSet<float>& hist);
00098   
00099   Image<double> getHistogramEnergy(const ImageSet<float>& hist);
00100  
00101   
00102   Image<PixRGB<byte> > getHistogramImage(const ImageSet<float>& hist, const int binSize=20);
00103   
00104   
00105 protected:
00106 
00107 };
00108 
00109 
00110 // ######################################################################
00111 /* So things look consistent in everyone's emacs... */
00112 /* Local Variables: */
00113 /* indent-tabs-mode: nil */
00114 /* End: */
00115 
00116 #endif //
Generated on Sun May 8 08:40:38 2011 for iLab Neuromorphic Vision Toolkit by  doxygen 1.6.3