00001 /*!@file Features/HistogramOfGradients.H */ 00002 00003 00004 // //////////////////////////////////////////////////////////////////// // 00005 // The iLab Neuromorphic Vision C++ Toolkit - Copyright (C) 2000-2005 // 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: Daniel Parks <danielfp@usc.edu> 00035 // $HeadURL$ 00036 // $Id$ 00037 // 00038 00039 #ifndef HistogramOfGradients_H_DEFINED 00040 #define HistogramOfGradients_H_DEFINED 00041 00042 #include "Util/Types.H" 00043 #include "Image/Image.H" 00044 #include "Image/Pixels.H" 00045 #include "Image/ImageSet.H" 00046 #include "SIFT/FeatureVector.H" 00047 00048 #include <vector> 00049 #include <string> 00050 00051 class JunctionHOG; 00052 class HistogramOfGradients 00053 { 00054 00055 private: 00056 // No static initializations are allowed for this class, use references instead (protect against slicing) 00057 HistogramOfGradients & operator=(const HistogramOfGradients & other); 00058 00059 public: 00060 //! Constructor 00061 HistogramOfGradients(bool normalize=true, Dims cellDims = Dims(8,8), bool fixedCells = false, int numOrientations=9, bool signedOrient=false); 00062 00063 virtual HistogramOfGradients *clone () { return new HistogramOfGradients(*this);} 00064 00065 //! Destructor 00066 virtual ~HistogramOfGradients(); 00067 00068 //! Calculate the gradient of 1-3 chanels of images 00069 virtual void calculateGradient(const Image<float>& img, const Image<float>& img2, const Image<float>& img3, Image<float>& gradmag, Image<float>&gradang); 00070 00071 //! Calculate histogram using a gradient 00072 virtual std::vector<float> createHistogramFromGradient(const Image<float>& gradmag, const Image<float>& gradang); 00073 00074 //! Create histogram of max of gradient across 1-3 channels of an image 00075 virtual std::vector<float> createHistogram(const Image<float>& img, const Image<float>& img2=Image<float>(), const Image<float>& img3=Image<float>()); 00076 00077 //! Normalize block using nearby blocks 00078 virtual std::vector<float> normalizeFeatureVector(FeatureVector featureVector); 00079 00080 //! Force angle to conform to oriSigned option and add to histogram 00081 virtual void addToBin(const float xf, const float yf, const float ang_in, const float mag, const bool oriSigned, FeatureVector &fv); 00082 00083 protected: 00084 //! Whether to normalize columns in the histogram 00085 bool itsNormalize; 00086 //! If fixed dims is true, itsCellDims is the number of cells in the histogram whose cell size depends on the input image 00087 //! If fixed dims is false, itsCellDims is the size of an individual cell, and the number of cells depends on the input image 00088 Dims itsCellDims; 00089 //! If true, fix the size of the histogram no matter the image size, if false, fix the size of the cell no matter the image size 00090 bool itsFixedDims; 00091 //! Number of bins to categorize orientations 00092 int itsOriBins; 00093 bool itsOriSigned; 00094 float itsEpsilon; 00095 00096 }; 00097 00098 00099 // ###################################################################### 00100 /* So things look consistent in everyone's emacs... */ 00101 /* Local Variables: */ 00102 /* indent-tabs-mode: nil */ 00103 /* End: */ 00104 00105 #endif //