Histogram.H

Go to the documentation of this file.
00001 /*!@file SIFT/Histogram.H Header file for histograms */
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: James Bonaiuto <bonaiuto@usc.edu>
00034 // $HeadURL: svn://isvn.usc.edu/software/invt/trunk/saliency/src/SIFT/Histogram.H $
00035 // $Id: Histogram.H 14762 2011-05-03 01:13:16Z siagian $
00036 //
00037 
00038 #ifndef HISTOGRAM_H_DEFINED
00039 #define HISTOGRAM_H_DEFINED
00040 
00041 #include "Image/Image.H"
00042 #include <vector>
00043 
00044 //! Histogram
00045 class Histogram
00046 {
00047 public :
00048   //! Constructor
00049   Histogram(const int size = 0);
00050 
00051   //! Constructor
00052   /*! Build a histogram with 256 bins from the pixel values in the image. */
00053   Histogram(const Image<byte>& img);
00054 
00055   //! Constructor
00056   /*! Copy the histogram from the raw input (CAUTION: we do not
00057     compute a histogram of the input values; we just copy the input
00058     histogram into our internal representation). */
00059   Histogram(const float* input, const int size);
00060 
00061   //! Constructor
00062   Histogram(std::vector<Histogram> histograms);
00063 
00064   //! Destructor
00065   ~Histogram();
00066 
00067   //! get a value from the histogram
00068   float getValue(const uint index) const;
00069 
00070   //! Access histogram through C array index interface
00071   float operator[](const uint index) const;
00072 
00073   //! add a value to the histogram
00074   void addValue(const uint index, const float value);
00075 
00076   //! add a value to the histogram, with linear interpolation
00077   void addValueInterp(const float index, const float value);
00078 
00079   //! Compute a histogram of the pixel values in an image
00080   void fill(const Image<byte>& img);
00081 
00082   //! get an image representation of the histogram
00083   Image<byte> getHistogramImage(const int w, const int h,
00084                                 const float mini = -1, const float maxi = -1);
00085 
00086   //! smooth the histogram
00087   void smooth();
00088 
00089   //! smooth the histogram
00090   //! using the inputted kernel
00091   void smooth(Image<double> kernel);
00092 
00093   //! Retrieve the peak of the histogram
00094   float findMax() const;
00095 
00096   //! Retrive the peak position and value
00097   void findMax(int &max_loc, float &max_val);
00098 
00099   //! Retrieve the valley of the histogram
00100   float findMin() const;
00101 
00102   //! Retrieve the min and max
00103   void findMinMax(double &min, double &max);
00104 
00105   //!Get distance between histograms
00106   double getDistance(const Histogram& hist);
00107 
00108   //! normalize the hist by a value
00109   //! if sum is -1 then use the sum of all values in the histogram
00110   void normalize(double sum = -1);
00111 
00112   //! Clear the histogram
00113   void clear();
00114 
00115   //! resize the histogram
00116   void resize(uint size);
00117 
00118   //! get the number of buckets in the histogram
00119   int getSize();
00120 
00121   //! get the number of buckets in the histogram
00122   uint size() const;
00123 
00124   //! get the Chi Square difference of the two histograms
00125   float getChiSqDiff(Histogram hist2);
00126 
00127   void divide(float div);
00128 
00129 private:
00130   std::vector<float> itsHistogram;
00131 };
00132 
00133 
00134 #endif
00135 
00136 // ######################################################################
00137 /* So things look consistent in everyone's emacs... */
00138 /* Local Variables: */
00139 /* indent-tabs-mode: nil */
00140 /* End: */
Generated on Sun May 8 08:42:16 2011 for iLab Neuromorphic Vision Toolkit by  doxygen 1.6.3