fancynorm.H

Go to the documentation of this file.
00001 /*!@file Image/fancynorm.H Intrafeature competition with maxNormalize(). */
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/Image/fancynorm.H $
00035 // $Id: fancynorm.H 8821 2007-10-11 19:45:28Z rjpeters $
00036 //
00037 
00038 #ifndef FANCYNORM_H_DEFINED
00039 #define FANCYNORM_H_DEFINED
00040 
00041 #include "Util/log.H"
00042 
00043 #include <string>
00044 
00045 /*! \defgroup MaxNorm max-normalization algorithms */
00046 //@{
00047 
00048 /*! @name Types of normalization (normtyp) */
00049 //@{
00050 
00051 enum MaxNormType {
00052   VCXNORM_NONE          = 0,  //!< no max-normalization, but may change range
00053   VCXNORM_MAXNORM       = 1,  //!< non-iterative maxnorm
00054   VCXNORM_FANCY         = 2,  //!< full implementation of fancy maxnorm
00055   VCXNORM_FANCYFAST     = 3,  //!< fast implementation of fancy maxnorm
00056   VCXNORM_FANCYONE      = 4,  //!< one-iteration only of fancy maxnorm
00057   VCXNORM_FANCYLANDMARK = 5,  //!< fancy maxnorm to find landmark
00058   VCXNORM_LANDMARK      = 6,  //!< to find landmarks
00059   VCXNORM_FANCYWEAK     = 7,  //!< Weak version of FancyOne
00060   VCXNORM_IGNORE        = 8,  //!< Do absolutely nothing, not even change range
00061   VCXNORM_SURPRISE      = 9,  //!< Like ignore but VCX will do something
00062   VCXNORM_FANCYVWEAK    = 10, //!< Very weak version of FancyOne
00063   VCXNORM_STDEV         = 11, //!< normalize map to have stdev=1, minval=0
00064   VCXNORM_STDEV0        = 12  //!< normalize map to have stdev=1, mean=0
00065   // if you add some new types here, also update the name list below!
00066 };
00067 
00068 /*! Have this value always equal to the largest of the VCXNORMs (used for
00069   range checking) */
00070 #define NBMAXNORMTYPES 13
00071 
00072 //! Get a name in clear for a given type
00073 inline const char* maxNormTypeName(const MaxNormType m)
00074 {
00075   static const char n[NBMAXNORMTYPES][14] = {
00076     "None", "Maxnorm", "Fancy", "FancyFast", "FancyOne", "FancyLandmark",
00077     "Landmark", "FancyWeak", "Ignore", "Surprise", "FancyVWeak", "Stdev",
00078     "Stdev0" };
00079 
00080   if (int(m) < 0 || int(m) >= NBMAXNORMTYPES)
00081     LFATAL("Invalid MaxNormType value %d (valid range is 0-%d inclusive)",
00082            int(m), NBMAXNORMTYPES);
00083 
00084   return n[int(m)];
00085 }
00086 
00087 /*! Always points to the default maxnorm operation */
00088 #define VCXNORM_DEFAULT VCXNORM_FANCY
00089 
00090 //@}
00091 
00092 /*! @name Additional parameters for fancynorm versions of the algorithm. */
00093 //@{
00094 const int FANCYITER = 5;   //!< default number of iterations
00095 const double FANCYESIG = 2;   //!< excitatory sigma as % of image size
00096 const double FANCYISIG = 25;  //!< inhibitory sigma as % of image size
00097 const double FANCYCOEX = 0.5; //!< excitatory coefficient (strength)
00098 const double FANCYCOIN = 1.5; //!< inhibitory coefficient (strength)
00099 const double FANCYINHI = 2.0; //!< strength of global inhibition
00100 
00101 const double FANCYG = 2.1; //!< for sigmoid normalization
00102 const double FANCYH = 2.0; //!< for sigmoid normalization
00103 const double FANCYS = 1.0; //!< for sigmoid normalization
00104 
00105 const int LRLEVEL = 2; //!< for tuned long-range excitation:
00106 
00107 //@}
00108 
00109 /*! @name Standard min/max bounds for maxNormalize(). */
00110 //@{
00111 
00112 //! upper bound for maxNormalize()
00113 const float MAXNORMMAX = 10.0f;
00114 //! lower bound for maxNormalize()
00115 const float MAXNORMMIN = 0.0f;
00116 //! upper bound for maxNormalizeFancyLandmark()
00117 const float MAXNORMLANDMARK = 255.0f;
00118 
00119 //@}
00120 
00121 
00122 template <class T> class Image;
00123 
00124 //! Generic implementation (select algorithm with \a normtyp).
00125 /*! Normalize between mi and ma and multiply by (ma - mean). Versions with
00126     more arguments implement the core within-feature spatial competition
00127     for salience. See papers for details. */
00128 template <class T>
00129 Image<T> maxNormalize(const Image<T>& src,
00130                       const T mi, const T ma,
00131                       const MaxNormType normtyp = VCXNORM_DEFAULT,
00132                       int nbiter = FANCYITER,
00133                       const Image<float>* lrexcit = 0);
00134 
00135 //! Specialized implementation (corresponds to VCXNORM_NONE).
00136 /*! No max-normalization, just normalize between \a mi and \a ma. */
00137 template <class T>
00138 Image<T> maxNormalizeNone(const Image<T>& src, const T mi, const T ma);
00139 
00140 //! Specialized implementation (corresponds to VCXNORM_MAXNORM).
00141 /*! maxNorm from Itti et al, IEEE-PAMI, 1998. */
00142 template <class T>
00143 Image<T> maxNormalizeStd(const Image<T>& src, const T mi, const T ma);
00144 
00145 //! Specialized implementation (corresponds to VCXNORM_FANCYFAST).
00146 /*! fancyNorm from Itti et al, JEI, 2001; FAST implementation. */
00147 template <class T>
00148 Image<T> maxNormalizeFancyFast(const Image<T>& src, const T mi, const T ma,
00149                                const int nbiter = FANCYITER);
00150 
00151 //! Specialized implementation (corresponds to VCXNORM_FANCY).
00152 /*! fancyNorm from Itti et al, JEI, 2001; FULL implementation. */
00153 template <class T>
00154 Image<T> maxNormalizeFancy(const Image<T>& src, const T mi, const T ma,
00155                            const int nbiter = FANCYITER,
00156                            const double weakness = 1.0,
00157                            const Image<float>* lrexcit = 0);
00158 
00159 //! Specialized implementation (corresponds to VCXNORM_FANCY).
00160 /*! fancyNorm from Itti et al, JEI, 2001; FULL implementation.
00161  adapted to find landmarks */
00162 template <class T>
00163 Image<T> maxNormalizeFancyLandmark(const Image<T>& src, const T mi, const T ma,
00164                            const int nbiter = FANCYITER);
00165 
00166 //! Specialized implementation (corresponds to VCXNORM_LANDMARK).
00167 /*! to find landmarks */
00168 template <class T>
00169 Image<T> maxNormalizeLandmark(const Image<T>& src, const T mi, const T ma);
00170 
00171 //! to find number of peaks in the image (used in landmark detection)
00172 template <class T>
00173 int findPeaks(const Image<T>& src, const T mi, const T ma,
00174               double& sum);
00175 
00176 //! to find the goodness of a map (used in landmark detection)
00177 template <class T>
00178 float goodness_map(const Image<T>& src);
00179 
00180 //! Specialized implementation (corresponds to VCXNORM_STDEV).
00181 /*! The output image is the result of normalizing the input image to
00182     have stdev=1 and minval=0, by simply dividing by the stdev of the
00183     original image and then subtracting the minval of the resulting
00184     image. We set minval=0, rather than the more natural mean=0,
00185     because maxNormalize functions traditionally return images with
00186     only non-negative values, since negative values will likely
00187     eventually be subject to a rectification. The choice of minval=0
00188     or mean=0 has no effect on the statistics of maps produced by
00189     summing several stdev-normalized maps; the resulting map itself
00190     will have the same stdev in either case, and the only difference
00191     will be a shift in its mean. */
00192 template <class T>
00193 Image<T> maxNormalizeStdev(const Image<T>& src);
00194 
00195 //! Specialized implementation (corresponds to VCXNORM_STDEV0).
00196 /*! The output image is the result of normalizing the input image to
00197     have mean=0 and stdev=1, by simply subtracting the mean of the
00198     original image and then dividing by the stdev of the original
00199     image. Beware that the resulting image will have negative values,
00200     which may be truncated by later rectification steps. */
00201 template <class T>
00202 Image<T> maxNormalizeStdev0(const Image<T>& src);
00203 
00204 //@}
00205 
00206 
00207 //! MaxNormType overload
00208 /*! Format is "name" as defined by maxNormTypeName() in MaxNormTypes.H */
00209 std::string convertToString(const MaxNormType val);
00210 //! MaxNormType overload
00211 /*! Format is "name" as defined by maxNormTypeName() in MaxNormTypes.H */
00212 void convertFromString(const std::string& str, MaxNormType& val);
00213 
00214 
00215 #endif
00216 
00217 // ######################################################################
00218 /* So things look consistent in everyone's emacs... */
00219 /* Local Variables: */
00220 /* indent-tabs-mode: nil */
00221 /* End: */
Generated on Sun May 8 08:40:49 2011 for iLab Neuromorphic Vision Toolkit by  doxygen 1.6.3