ImageSetOps.H

Go to the documentation of this file.
00001 /*!@file Image/ImageSetOps.H Free functions operating on sets of images
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/ImageSetOps.H $
00035 // $Id: ImageSetOps.H 14633 2011-03-23 22:55:54Z dberg $
00036 //
00037 
00038 #ifndef IMAGESET_OPS_H_DEFINED
00039 #define IMAGESET_OPS_H_DEFINED
00040 
00041 #include "Util/Types.H" // for uint
00042 
00043 class Dims;
00044 template <class T> class Image;
00045 template <class T> class ImageSet;
00046 template <class T> class Range;
00047 
00048 // ############################################################
00049 // ############################################################
00050 /*! @name ImageSet processing functions
00051 
00052     Not all of these functions are templates, simply because alternate
00053     versions aren't currently needed.
00054 */
00055 //@{
00056 
00057 //! Returns true if all images in the set are the same size.
00058 /*! Also returns true for the empty set. */
00059 template <class T_or_RGB>
00060 bool isHomogeneous(const ImageSet<T_or_RGB>& x);
00061 
00062 //! Check whether the pyramid is dyadic.
00063 /*! A dyadic pyramid is one in which each level is one half the width
00064     and one half the height of the preceding level. NOTE that this
00065     function is defined here, in ImageSetOps.H, rather than in
00066     Pyramid_Ops.H, in order to avoid a cyclic dependency between those
00067     two modules. ImageSetOps needs isDyadic() in order to implement
00068     makeImageArray(). */
00069 template <class T_or_RGB>
00070 bool isDyadic(const ImageSet<T_or_RGB>& pyr);
00071 
00072 //! Returns the sum of all the images in the set. Requires isHomogeneous().
00073 template <class T>
00074 Image<T> sum(const ImageSet<T>& x);
00075 
00076 //! Returns the sum of all the images in the set. Requires isHomogeneous().
00077 template <class T>
00078 Image<T> mean(const ImageSet<T>& x);
00079 
00080 //! Returns the overall range of all images in the set.
00081 template <class T>
00082 Range<T> rangeOf(const ImageSet<T>& x);
00083 
00084 //! Make an ImageSet from the s'th level from each of the N input sets.
00085 /*! This is useful, for example, in transforming an array of ImageSets
00086     from multiple-scales-per-set/one-orientation-per-set into the
00087     reverse, multiple-orientations-per-set/one-scale-per-set.
00088 */
00089 template <class T>
00090 ImageSet<T> takeSlice(const ImageSet<T>* sets, uint N, uint s);
00091 
00092 //! Make a single image-array from the set (see concatArray() in Image_ShapeOps).
00093 /*! @param Nx Number of columns; if negative, the result will be roughly square.
00094     @param grid_width Pixel width of grid separators to be overlaid on image.
00095     @param grid_color Color in which to draw grid.
00096     @param destX Width to which each image is reshaped;
00097                           if negative, reshape to size of first image.
00098     @param destY Height to which each image is reshaped;
00099                           if negative, reshape to size of first image.
00100 */
00101 template <class T>
00102 Image<T> makeImageArray(const ImageSet<T>& x,
00103                         int Nx = -1, int grid_width = 1, T grid_color = T(),
00104                         int destX = -1, int destY = -1);
00105 
00106 //! Make a new ImageSet by downscaling the input by the given number of octaves.
00107 template <class T>
00108 ImageSet<T> reduce(const ImageSet<T>& x, int octaves);
00109 
00110 //! Make a new ImageSet by rescaling each input image to the given dimensions.
00111 template <class T>
00112 ImageSet<T> rescale(const ImageSet<T>& x, const Dims& dims);
00113 
00114 //! Generate a set of oriented filter outputs for a given set of orientations.
00115 /*! Caller is responsible for passing input in the form of
00116     (image - lowPass(image)) */
00117 ImageSet<float> orientedFilterSet(const Image<float>& lowPassedInput,
00118                                   float period,
00119                                   const float* angles, const uint numAngles);
00120 
00121 //!split the positive and negative values for each image in x
00122 void splitPosNeg(const ImageSet<float>& x, ImageSet<float>& pos, ImageSet<float>& neg);
00123 
00124 //@}
00125 
00126 
00127 // ############################################################
00128 // ############################################################
00129 /*! @name ImageSet mathematical operators
00130 
00131     This set of operators is obviously incomplete; more operators can
00132     be added as they are needed. There are three basic kinds of
00133     operators:
00134 
00135     (1) ImageSet-scalar ops. These place no restrictions on the
00136         ImageSet.
00137 
00138     (2) ImageSet-Image ops. These require the ImageSet to be
00139         homogeneous (all images the same size), and require the Image
00140         argument to be the same size as well.
00141 
00142     (3) ImageSet-ImageSet ops. These require the two sets to have the
00143         same number of images, and for each pair of corresponding
00144         images to be the same size.
00145 */
00146 
00147 //! x -= y, for each image in x; requires isHomogeneous(x).
00148 template <class T>
00149 ImageSet<T>& operator-=(ImageSet<T>& x, const Image<T>& y);
00150 
00151 //! x += y, for each image in x; requires isHomogeneous(x).
00152 template <class T>
00153 ImageSet<T>& operator+=(ImageSet<T>& x, const Image<T>& y);
00154 
00155 //! x *= y, for each image in x; requires isHomogeneous(x).
00156 template <class T>
00157 ImageSet<T>& operator*=(ImageSet<T>& x, const Image<T>& y);
00158 
00159 //! x /= y, for each image in x; requires isHomogeneous(x).
00160 template <class T>
00161 ImageSet<T>& operator/=(ImageSet<T>& x, const Image<T>& y);
00162 
00163 //! x -= v, for each image in x
00164 template <class T>
00165 ImageSet<T>& operator-=(ImageSet<T>& x, const T& v);
00166 
00167 //! x += v, for each image in x
00168 template <class T>
00169 ImageSet<T>& operator+=(ImageSet<T>& x, const T& v);
00170 
00171 //! x *= v, for each image in x
00172 template <class T>
00173 ImageSet<T>& operator*=(ImageSet<T>& x, const T& v);
00174 
00175 //! x /= v, for each image in x
00176 template <class T>
00177 ImageSet<T>& operator/=(ImageSet<T>& x, const T& v);
00178 
00179 //! x - v, for each image in x
00180 template <class T>
00181 ImageSet<T> operator-(ImageSet<T>& x, const T& v);
00182 
00183 //! x + v, for each image in x
00184 template <class T>
00185 ImageSet<T> operator+(ImageSet<T>& x, const T& v);
00186 
00187 //! x * v, for each image in x
00188 template <class T>
00189 ImageSet<T> operator*(ImageSet<T>& x, const T& v);
00190 
00191 //! x / v, for each image in x
00192 template <class T>
00193 ImageSet<T> operator/(ImageSet<T>& x, const T& v);
00194 
00195 //! x -= y, for each image in x with the respective image in y
00196 template <class T>
00197 ImageSet<T>& operator-=(ImageSet<T>& x, const ImageSet<T>& y);
00198 
00199 //! x += y, for each image in x with the respective image in y
00200 template <class T>
00201 ImageSet<T>& operator+=(ImageSet<T>& x, const ImageSet<T>& y);
00202 
00203 //! x *= y, for each image in x with the respective image in y
00204 template <class T>
00205 ImageSet<T>& operator*=(ImageSet<T>& x, const ImageSet<T>& y);
00206 
00207 //! x /= y, for each image in x with the respective image in y
00208 template <class T>
00209 ImageSet<T>& operator/=(ImageSet<T>& x, const ImageSet<T>& y);
00210 
00211 //! clampedDiff(b,c) for each image
00212 template <class T>
00213 ImageSet<T> clampedDiff(const ImageSet<T>& b, const ImageSet<T>& c);
00214 
00215 //@}
00216 
00217 // ############################################################
00218 // ############################################################
00219 /*! @name In-place ImageSet modification functions
00220 
00221     Any functions which modify an ImageSet in-place should adhere to
00222     the following conventions:
00223 
00224     (1) The to-be-modified ImageSet should be passed by non-const
00225         reference as the first argument to the function.
00226 
00227     (2) The function should be named with a "do" prefix, to
00228         distinguish it from functions that work by returning a new
00229         result instead of modifying an argument in place.
00230 
00231     Not all of these functions are templates, simply because alternate
00232     versions aren't currently needed.
00233 */
00234 //@{
00235 
00236 //! x = rectify(x), for each image in x
00237 template <class T>
00238 void doRectify(ImageSet<T>& x);
00239 
00240 //! For each image in x, replace values < threshold with newval
00241 template <class T>
00242 void doLowThresh(ImageSet<T>& x, const T threshold, const T newval = T());
00243 
00244 //! For each image in x, replace values whose abs is < threshold with newval
00245 template <class T>
00246 void doLowThreshAbs(ImageSet<T>& x, const T threshold, const T newval = T());
00247 
00248 //! For each image in x, take the square root at every pixel
00249 template <class T>
00250 void doSqrt(ImageSet<T>& x);
00251 
00252 //! For each image in x, take the square at every pixel
00253 template <class T>
00254 void doSquared(ImageSet<T>& x);
00255 
00256 //! Subtract the overall mean from each image
00257 void doMeanNormalize(ImageSet<float>& x);
00258 
00259 //! Normalize so overall max value is 1.0
00260 void doOneNormalize(ImageSet<float>& x);
00261 
00262 //! Divide image by the local image energy, then subtract overall mean.
00263 void doEnergyNorm(ImageSet<float>& x);
00264 
00265 //! Multiply each image by the corresponding bias
00266 void doApplyBiases(ImageSet<float>& x, const float* biases);
00267 
00268 //! x += v * y, for each image in x and y, respectively
00269 void doAddWeighted(ImageSet<float>& x, const ImageSet<float>& y, float v);
00270 
00271 //! x = v, for each image in x
00272 void doClear(ImageSet<float>& x, float v);
00273 
00274 //@}
00275 
00276 #endif // !IMAGESET_OPS_H_DEFINED
00277 
00278 // ######################################################################
00279 /* So things look consistent in everyone's emacs... */
00280 /* Local Variables: */
00281 /* indent-tabs-mode: nil */
00282 /* End: */
Generated on Sun May 8 08:40:54 2011 for iLab Neuromorphic Vision Toolkit by  doxygen 1.6.3