c_integer_math_ops.h

Go to the documentation of this file.
00001 /*!@file Image/c_integer_math_ops.h Fixed-point integer math versions of some of our floating-point Image functions */
00002 
00003 // //////////////////////////////////////////////////////////////////// //
00004 // The iLab Neuromorphic Vision C++ Toolkit - Copyright (C) 2000-2005   //
00005 // by the 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: Rob Peters <rjpeters at usc dot edu>
00034 // $HeadURL: svn://isvn.usc.edu/software/invt/trunk/saliency/src/Image/c_integer_math_ops.h $
00035 // $Id: c_integer_math_ops.h 7408 2006-11-04 00:49:56Z rjpeters $
00036 //
00037 
00038 #ifndef IMAGE_C_INTEGER_MATH_OPS_H_DEFINED
00039 #define IMAGE_C_INTEGER_MATH_OPS_H_DEFINED
00040 
00041 #ifdef __cplusplus
00042 extern "C"
00043 {
00044 #endif
00045 
00046   void c_intg_low_pass_5_x_dec_x_manybits(const int* src,
00047                                            const int w, const int h,
00048                                            int* dst,
00049                                            const int w2);
00050 
00051   void c_intg_low_pass_5_y_dec_y_manybits(const int* src,
00052                                            const int w, const int h,
00053                                            int* dst,
00054                                            const int h2);
00055 
00056   void c_intg_low_pass_5_x_dec_x_fewbits(const int* src,
00057                                            const int w, const int h,
00058                                            int* dst,
00059                                            const int w2);
00060 
00061   void c_intg_low_pass_5_y_dec_y_fewbits(const int* src,
00062                                            const int w, const int h,
00063                                            int* dst,
00064                                            const int h2);
00065 
00066   void c_intg_low_pass_5_x_dec_x_fewbits_optim(const int* src,
00067                                            const int w, const int h,
00068                                            int* dst,
00069                                            const int w2);
00070 
00071   void c_intg_low_pass_5_y_dec_y_fewbits_optim(const int* src,
00072                                            const int w, const int h,
00073                                            int* dst,
00074                                            const int h2);
00075 
00076   /// Convolve in the x direction with a 9-point binomial kernel
00077   /** The kernel is {1, 8, 28, 56, 70, 56, 28, 8, 1}, summing to 256
00078 
00079       @param src pointer to the source image, w*h row-major
00080       @param w width of the source and destination images
00081       @param h height of the source and destination images
00082       @param dst pointer to the destination image, w*h row-major
00083 
00084       Internally, this algorithm divides each of the source values by
00085       the sum of the filter coefficients, then multiplies by the
00086       coefficient and accumulates. Thus it is appropriate when the
00087       input has many precision bits and would overflow if multiplied
00088       by the fitler coefficient without dividing first, but is not
00089       appropriate when the input has few bits and would underflow as a
00090       result of the early division. For a 32-bit int, a reasonable
00091       cutoff point is 18 bits -- if the input has 18 bits or more, use
00092       this algorithm, otherwise use the fewbits functions (see
00093       below).
00094    */
00095   void c_intg_low_pass_9_x_manybits(const int* src,
00096                                      const int w, const int h,
00097                                      int* dst);
00098 
00099   /// Convolve in the y direction with a 9-point binomial kernel
00100   /** Like c_intg_low_pass_9_y_manybits(), but convolves in the y
00101       direction instead of the x direction. */
00102   void c_intg_low_pass_9_y_manybits(const int* src,
00103                                      const int w, const int h,
00104                                      int* dst);
00105 
00106   /// Convolve in the x direction with a 9-point binomial kernel
00107   /** The kernel is {1, 8, 28, 56, 70, 56, 28, 8, 1}, summing to 256
00108 
00109       @param src pointer to the source image, w*h row-major
00110       @param w width of the source and destination images
00111       @param h height of the source and destination images
00112       @param dst pointer to the destination image, w*h row-major
00113 
00114       Internally, this algorithm multiplies each input pixel by the
00115       corresponding filter coefficient, accumulates across the 9
00116       filter points, and then divides by the sum of the filter
00117       coefficients. Thus it is appropriate when the input relatively
00118       few precision bits giving room for doing the multiply/accumulate
00119       prior to the divide, but not when the input has many precision
00120       bits and would require an early division to avoid overflow. For
00121       a 32-bit int, a reasonable cutoff point is 18 bits -- if the
00122       input has fewer than 18 bits, use this algorithm, otherwise use
00123       the manybits functions (see above).
00124    */
00125   void c_intg_low_pass_9_x_fewbits(const int* src,
00126                                      const int w, const int h,
00127                                      int* dst);
00128 
00129   /// Convolve in the y direction with a 9-point binomial kernel
00130   /** Like c_intg_low_pass_9_y_fewbits(), but convolves in the y
00131       direction instead of the x direction. */
00132   void c_intg_low_pass_9_y_fewbits(const int* src,
00133                                      const int w, const int h,
00134                                      int* dst);
00135 
00136   /// Like c_intg_low_pass_9_x_fewbits() but uses optimized filter coefficients
00137   void c_intg_low_pass_9_x_fewbits_optim(const int* src,
00138                                          const int w, const int h,
00139                                          int* dst);
00140 
00141   /// Like c_intg_low_pass_9_y_fewbits() but uses optimized filter coefficients
00142   void c_intg_low_pass_9_y_fewbits_optim(const int* src,
00143                                          const int w, const int h,
00144                                          int* dst);
00145 
00146   /// function for reasonably large images
00147   void c_intg_x_filter_clean_manybits(const int* src,
00148                                        const int w, const int h,
00149                                        const int* hf_flipped, const int hfs,
00150                                        const int shiftbits,
00151                                        int* dst);
00152 
00153   /// function for reasonably large images
00154   void c_intg_x_filter_clean_fewbits(const int* src,
00155                                        const int w, const int h,
00156                                        const int* hf_flipped, const int hfs,
00157                                        const int shiftbits,
00158                                        int* dst);
00159 
00160   /// special function for very small images
00161   void c_intg_x_filter_clean_small_manybits(const int* src,
00162                                              const int w, const int h,
00163                                              const int* hf_flipped, const int hfs,
00164                                              const int shiftbits,
00165                                              int* dst);
00166 
00167   /// special function for very small images
00168   void c_intg_x_filter_clean_small_fewbits(const int* src,
00169                                              const int w, const int h,
00170                                              const int* hf_flipped, const int hfs,
00171                                              const int shiftbits,
00172                                              int* dst);
00173 
00174   /// function for reasonably large images
00175   void c_intg_y_filter_clean_manybits(const int* src,
00176                                        const int w, const int h,
00177                                        const int* vf_flipped, const int vfs,
00178                                        const int shiftbits,
00179                                        int* dst);
00180 
00181   /// function for reasonably large images
00182   void c_intg_y_filter_clean_fewbits(const int* src,
00183                                        const int w, const int h,
00184                                        const int* vf_flipped, const int vfs,
00185                                        const int shiftbits,
00186                                        int* dst);
00187 
00188   /// special function for very small images
00189   void c_intg_y_filter_clean_small_manybits(const int* src,
00190                                              const int w, const int h,
00191                                              const int* vf_flipped, const int vfs,
00192                                              const int shiftbits,
00193                                              int* dst);
00194 
00195   /// special function for very small images
00196   void c_intg_y_filter_clean_small_fewbits(const int* src,
00197                                              const int w, const int h,
00198                                              const int* vf_flipped, const int vfs,
00199                                              const int shiftbits,
00200                                              int* dst);
00201 
00202 #ifdef __cplusplus
00203 }
00204 #endif
00205 
00206 // ######################################################################
00207 /* So things look consistent in everyone's emacs... */
00208 /* Local Variables: */
00209 /* mode: c++ */
00210 /* indent-tabs-mode: nil */
00211 /* End: */
00212 
00213 #endif // IMAGE_C_INTEGER_MATH_OPS_H_DEFINED
Generated on Sun May 8 08:40:48 2011 for iLab Neuromorphic Vision Toolkit by  doxygen 1.6.3