00001 /*!@file Image/Kernels.H Functions to construct various kinds of 00002 filter kernels 00003 */ 00004 00005 // //////////////////////////////////////////////////////////////////// // 00006 // The iLab Neuromorphic Vision C++ Toolkit - Copyright (C) 2001 by the // 00007 // University of Southern California (USC) and the iLab at USC. // 00008 // See http://iLab.usc.edu for information about this project. // 00009 // //////////////////////////////////////////////////////////////////// // 00010 // Major portions of the iLab Neuromorphic Vision Toolkit are protected // 00011 // under the U.S. patent ``Computation of Intrinsic Perceptual Saliency // 00012 // in Visual Environments, and Applications'' by Christof Koch and // 00013 // Laurent Itti, California Institute of Technology, 2001 (patent // 00014 // pending; application number 09/912,225 filed July 23, 2001; see // 00015 // http://pair.uspto.gov/cgi-bin/final/home.pl for current status). // 00016 // //////////////////////////////////////////////////////////////////// // 00017 // This file is part of the iLab Neuromorphic Vision C++ Toolkit. // 00018 // // 00019 // The iLab Neuromorphic Vision C++ Toolkit is free software; you can // 00020 // redistribute it and/or modify it under the terms of the GNU General // 00021 // Public License as published by the Free Software Foundation; either // 00022 // version 2 of the License, or (at your option) any later version. // 00023 // // 00024 // The iLab Neuromorphic Vision C++ Toolkit is distributed in the hope // 00025 // that it will be useful, but WITHOUT ANY WARRANTY; without even the // 00026 // implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR // 00027 // PURPOSE. See the GNU General Public License for more details. // 00028 // // 00029 // You should have received a copy of the GNU General Public License // 00030 // along with the iLab Neuromorphic Vision C++ Toolkit; if not, write // 00031 // to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, // 00032 // Boston, MA 02111-1307 USA. // 00033 // //////////////////////////////////////////////////////////////////// // 00034 // 00035 // Primary maintainer for this file: Rob Peters <rjpeters@klab.caltech.edu> 00036 // $HeadURL: svn://isvn.usc.edu/software/invt/trunk/saliency/src/Image/Kernels.H $ 00037 // $Id: Kernels.H 12821 2010-02-11 07:15:07Z itti $ 00038 // 00039 00040 #ifndef IMAGE_KERNELS_H_DEFINED 00041 #define IMAGE_KERNELS_H_DEFINED 00042 00043 #include "Util/Types.H" // for byte 00044 #include "Image/Pixels.H" //forPixRGB 00045 #include <complex> 00046 00047 00048 class Dims; 00049 template <class T> class Point2D; 00050 template <class T> class Image; 00051 00052 //! Create a DoG kernel for HMax 00053 template <class T> 00054 Image<T> dogFilterHmax(const float theta, const float gamma, const int halfsize, const float div); 00055 00056 //! Create a DoG kernel; if halfsize is 0, compute it automatically 00057 template <class T> 00058 Image<T> dogFilter(const float stddev, const float theta, 00059 const int halfsize = 0); 00060 00061 //! Create a non oriented DoG kernel; if halfsize is 0, compute it automatically 00062 template <class T> 00063 Image<T> dogFilter(const float stddev, const int halfsize = 0); 00064 00065 //! Create a dog kernel for HMAX 00066 template <class T> 00067 Image<T> dogFilterHmax(const float stddev, const float theta, 00068 const int cBegin, const int cEnd); 00069 00070 00071 //Create a Gabor Kernel including color 00072 Image<PixRGB<byte> > gaborFilterRGB(const float stddev, const float freq, 00073 const float theta,const float hueShift); 00074 00075 //! Create a Gabor kernel 00076 template <class T> 00077 Image<T> gaborFilter(const float stddev, const float period, 00078 const float phase, const float theta, 00079 const float = 0.0f, const float ampl = 1.0f); 00080 00081 //! Create a Gabor kernel with a a given scale and angle (in radians) 00082 template <class T> 00083 Image<T> gaborFilter(const float scale, const float theta); 00084 00085 //! Create a Gabor kernel with default 1*sigma^2 instead of 2*sigma^2 00086 /*! this is essentailly used in some psycho metric experiments (for instance 00087 , Polat and Sagi, 1994) instead 00088 of 2*sigma^2 so it is included here, if your weird you may make sigMod 00089 something other than 1.0 (or 2.0). As always feel free to be loopy */ 00090 template <class T> 00091 Image<T> gaborFilter2(const float stddev, const float period, 00092 const float phase, const float theta, 00093 const float sigMod = 1.0F, 00094 const float amplitude = 1.0F); 00095 00096 //! Produces a Gabor kernel with optionally unequal major+minor axis lengths. 00097 /*!@param size determines the filter size (in pixels) - in the default case 00098 (-1), the size is computed from the stddev*/ 00099 Image<float> gaborFilter3(const float major_stddev, const float minor_stddev, 00100 const float period, const float phase, 00101 const float theta, int size = -1); 00102 00103 //! Create a 2D gaussian, compatible with gaborFilter2 for mask purposes 00104 template <class T> 00105 Image<T> gaussian2D(const float stddev, const float sigMod = 1.0F, 00106 const float amplitude = 255.0F); 00107 00108 //! Create a 2D Gaussian blob centered at given coords 00109 template <class T> 00110 Image<T> gaussianBlob(const Dims& dims, const Point2D<int>& center, 00111 const float sigmaX, const float sigmaY); 00112 00113 //! Create a 2D Gaussian blob centered at given coords, with peak value = 1.0 00114 template <class T> 00115 Image<T> gaussianBlobUnnormalized(const Dims& dims, const Point2D<int>& center, 00116 const float sigmaX, const float sigmaY); 00117 00118 //! Create a 1D binomial distribution kernel (shape of sz-by-1). 00119 /*! These kernels are normalized to sum to 1, and are used (implicitly) in 00120 the various lowPass*() functions. */ 00121 Image<float> binomialKernel(const int sz); 00122 00123 //! Create a sinusoidal grating 00124 template <class T> 00125 Image<T> grating(const int width, const int height, 00126 const float period, const float phase, 00127 const float theta); 00128 00129 //! Generate 1D gaussian 00130 /*! @param coeff a coefficient so that the peak of the Gaussian has the value 00131 coeff. If coeff is given as 0.0, then it will be computed internally as 00132 1/(sigma*sqrt(2*pi)), i.e., the normal Gaussian coefficient. 00133 @param sigma the Gaussian standard deviation, in pixels 00134 @param maxhw maximum allower filter half-width. If maxhw is 0 there 00135 is no limit. 00136 @param threshperc cut the spatial extent of the kernel so that only 00137 values greater than threshperc times the max remain in the 00138 kernel. This allows us to automatically compute the appropriate 00139 kernel size to use for a given sigma and approximation tolerance 00140 given by threshpec. */ 00141 template <class T> 00142 Image<T> gaussian(const float coeff, const float sigma, const int maxhw, 00143 const float threshperc = 1.0); 00144 00145 //! Build a long-range excitatory filter 00146 template <class T> 00147 Image<T> longRangeExcFilter(const float factor, const float orient); 00148 00149 //! Generate a fixation mask, i.e., a Gaussian blob 00150 template <class T> 00151 Image<T> fixationMask(const Dims& dims, const Point2D<int>& fixation, 00152 const float pixperdeg, const T maxval, 00153 const float sigma = 0.5f); 00154 00155 //! Generate a fixation mask, adding it to existing mask 00156 template <class T> 00157 Image<T> fixationMask(const Image<T>& mask, const Point2D<int>& fixation, 00158 const float pixperdeg, const T maxval, 00159 const float sigma = 0.5f); 00160 00161 //! Return an image of Dimensions d filled with 255s 00162 Image<byte> twofiftyfives(Dims d); 00163 00164 //! Return an image of width w and height h filled with 255s 00165 Image<byte> twofiftyfives(int w, int h); 00166 00167 //! Return a square image of width w filled with 255s 00168 Image<byte> twofiftyfives(int w); 00169 00170 #endif // !IMAGE_KERNELS_H_DEFINED 00171 00172 // ###################################################################### 00173 /* So things look consistent in everyone's emacs... */ 00174 /* Local Variables: */ 00175 /* indent-tabs-mode: nil */ 00176 /* End: */