wrap_c_cuda.h

Go to the documentation of this file.
00001 
00002 /*!@file CUDA/wrap_c_cuda.h CUDA/GPU optimized saliency code */
00003 
00004 // //////////////////////////////////////////////////////////////////// //
00005 // The iLab Neuromorphic Vision C++ Toolkit - Copyright (C) 2000-2005   //
00006 // by the University of Southern California (USC) and the iLab at USC.  //
00007 // See http://iLab.usc.edu for information about this project.          //
00008 // //////////////////////////////////////////////////////////////////// //
00009 // Major portions of the iLab Neuromorphic Vision Toolkit are protected //
00010 // under the U.S. patent ``Computation of Intrinsic Perceptual Saliency //
00011 // in Visual Environments, and Applications'' by Christof Koch and      //
00012 // Laurent Itti, California Institute of Technology, 2001 (patent       //
00013 // pending; application number 09/912,225 filed July 23, 2001; see      //
00014 // http://pair.uspto.gov/cgi-bin/final/home.pl for current status).     //
00015 // //////////////////////////////////////////////////////////////////// //
00016 // This file is part of the iLab Neuromorphic Vision C++ Toolkit.       //
00017 //                                                                      //
00018 // The iLab Neuromorphic Vision C++ Toolkit is free software; you can   //
00019 // redistribute it and/or modify it under the terms of the GNU General  //
00020 // Public License as published by the Free Software Foundation; either  //
00021 // version 2 of the License, or (at your option) any later version.     //
00022 //                                                                      //
00023 // The iLab Neuromorphic Vision C++ Toolkit is distributed in the hope  //
00024 // that it will be useful, but WITHOUT ANY WARRANTY; without even the   //
00025 // implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR      //
00026 // PURPOSE.  See the GNU General Public License for more details.       //
00027 //                                                                      //
00028 // You should have received a copy of the GNU General Public License    //
00029 // along with the iLab Neuromorphic Vision C++ Toolkit; if not, write   //
00030 // to the Free Software Foundation, Inc., 59 Temple Place, Suite 330,   //
00031 // Boston, MA 02111-1307 USA.                                           //
00032 // //////////////////////////////////////////////////////////////////// //
00033 //
00034 // Primary maintainer for this file:
00035 // $HeadURL: svn://isvn.usc.edu/software/invt/trunk/saliency/src/CUDA/wrap_c_cuda.h $
00036 // $Id: wrap_c_cuda.h 12962 2010-03-06 02:13:53Z irock $
00037 //
00038 
00039 #ifndef CUDA_WRAP_C_CUDA_H_DEFINED
00040 #define CUDA_WRAP_C_CUDA_H_DEFINED
00041 #ifdef __cplusplus
00042 extern "C"
00043 {
00044 #endif
00045 
00046 #include "cudadefs.h"
00047 
00048 /*! Note that src and dst should have been allocated already by the
00049     caller in DEVICE memory, and source data should have been copied
00050     to src. The caller may have to copy the result back to host memory
00051     if no further GPU processing is needed. */
00052 
00053 // Declare all host callable functions here
00054 
00055 //! Get double color opponency maps
00056 void cuda_c_getRGBY(const float3_t *src, float *rgptr, float *byptr, const float thresh,
00057                     const float min_range, const float max_range,
00058                     const int w, const int h, const int tile_width, const int tile_height);
00059 
00060 //! Convert luminance to an RGB formatted image (which will still be grayscale)
00061 void cuda_c_toRGB(float3_t *dst, const float *src,int sz, const int tile_len);
00062 
00063 //! Get color components of an RGB image
00064 void cuda_c_getComponents(const float3_t *srcptr, float *rptr, float *gptr, float *bptr, int w, int h, int tile_width, int tile_height);
00065 
00066 //! Get luminance using (r+g+b)/3 calculation
00067 void cuda_c_luminance(float3_t *aptr, float *dptr, int w, int h, int tile_width, int tile_height);
00068 
00069 //! Get luminance using Matlab's NTSC calculation
00070 void cuda_c_luminanceNTSC(float3_t *aptr, float *dptr, int w, int h, int tile_width, int tile_height);
00071 
00072 //! Draw a filled in rectangle on top of an image with a particular intensity
00073 void cuda_c_drawFilledRect(float *dst, int top, int left, int bottom, int right, const float intensity, const int w, const int h, const int tile_width, const int tile_height);
00074 
00075 //! Draw a filled in rectangle on top of an image with a particular intensity
00076 void cuda_c_drawFilledRectRGB(float3_t *dst, int top, int left, int bottom, int right, const float3_t *color, const int w, const int h, const int tile_width, const int tile_height);
00077 
00078 
00079 //! Convolve and decimate in X direction with 5-tap lowpass filter
00080 void cuda_c_lowpass_5_x_dec_x(const float* src, const unsigned int w, const unsigned int h, float* dst, int tile_width);
00081 
00082 //! Convolve and decimate in Y direction with 5-tap lowpass filter
00083 void cuda_c_lowpass_5_y_dec_y(const float* src, const unsigned int w, const unsigned int h, float* dst, int tile_width, int tile_height);
00084 
00085 //! Convolve in X direction with 9-tap lowpass filter
00086 void cuda_c_lowpass_9_x(const float* src, const unsigned int w, const unsigned int h, float* dst, int tile_width);
00087 
00088 //! Convolve in Y direction with 9-tap lowpass filter
00089 void cuda_c_lowpass_9_y(const float* src, const unsigned int w, const unsigned int h, float* dst, int tile_width, int tile_height);
00090 
00091 //! Convolve and decimate in X direction with 9-tap lowpass filter
00092 void cuda_c_lowpass_9_x_dec_x(const float* src, const unsigned int w, const unsigned int h, float* dst, const int dw, const int dh, int tile_width);
00093 
00094 //! Convolve and decimate in Y direction with 9-tap lowpass filter
00095 void cuda_c_lowpass_9_y_dec_y(const float* src, const unsigned int w, const unsigned int h, float* dst, const int dw, const int dh, int tile_width, int tile_height);
00096 
00097 //! Convolve and decimate in X direction with 9-tap lowpass filter using texture memory
00098 void cuda_c_lowpass_texture_9_x_dec_x(const float *src, int w, int h, float *dst, int dw, int dh, int tile_width, int tile_height);
00099 
00100 //! Convolve and decimate in Y direction with 9-tap lowpass filter using texture memory
00101 void cuda_c_lowpass_texture_9_y_dec_y(const float *src, int w, int h, float *dst, int dw, int dh, int tile_width, int tile_height);
00102 
00103 //! Convolve in X direction with 5-tap lowpass filter
00104 void cuda_c_lowpass_5_x(const float* src, const unsigned int w, const unsigned int h, float* dst, int tile_width);
00105 
00106 //! Convolve in Y direction with 5-tap lowpass filter
00107 void cuda_c_lowpass_5_y(const float* src, const unsigned int w, const unsigned int h, float* dst, int tile_width, int tile_height);
00108 
00109 //! Convolve in X direction with 3-tap lowpass filter
00110 void cuda_c_lowpass_3_x(const float* src, const unsigned int w, const unsigned int h, float* dst, int tile_width);
00111 
00112 //! Convolve in Y direction with 3-tap lowpass filter
00113 void cuda_c_lowpass_3_y(const float* src, const unsigned int w, const unsigned int h, float* dst, int tile_width, int tile_height);
00114 
00115 //! Decimate image in the X and Y directions by factors
00116 void cuda_c_dec_xy(const float *src,  float* dst, const int x_factor, const int y_factor, const unsigned int w, const unsigned int h, int tile_width);
00117 
00118 //! Decimate image in X direction
00119 void cuda_c_dec_x(const float *src,  float* dst, const int x_factor, const unsigned int w, const unsigned int h, int tile_width);
00120 
00121 //! Decimate image in Y direction
00122 void cuda_c_dec_y(const float *src,  float* dst, const int y_factor, const unsigned int w, const unsigned int h, int tile_width);
00123 
00124 //! Take a local average of size scalex by scaley
00125 void cuda_c_quickLocalAvg(const float *in, float *res, float fac, int lw, int lh, int sw, int sh, int tile_width, int tile_height);
00126 
00127 //! Take a local average of 2x2 blocks
00128 void cuda_c_quickLocalAvg2x2(const float *in, float *res, int lw, int lh, int sw, int sh, int tile_width, int tile_height);
00129 
00130 //! Take a local max of size scalex by scaley
00131 void cuda_c_quickLocalMax(const float *in, float *res, int lw, int lh, int sw, int sh, int tile_width, int tile_height);
00132 
00133 //! Rescale image using bilinear interpolation
00134 void cuda_c_rescaleBilinear(const float *src, float *res, float sw, float sh, int orig_w, int orig_h, int new_w, int new_h, int tile_width, int tile_height);
00135 
00136 //! Rescale RGB image using bilinear interpolation
00137 void cuda_c_rescaleBilinearRGB(const float3_t *src, float3_t *res, float sw, float sh, int orig_w, int orig_h, int new_w, int new_h, int tile_width, int tile_height);
00138 
00139 //! Rectify image
00140 void cuda_c_inplaceRectify(float *ptr, const int tile_len, const int sz);
00141 
00142 //! Clamp image
00143 void cuda_c_inplaceClamp(float *ptr, const float cmin, const float cmax, const int tile_len, const int sz);
00144 
00145 //! Normalize an image inplace given the old min/max and the new min max
00146 void cuda_c_inplaceNormalize(float *src, const float *omin, const float *omax, const float nmin, const float nmax, const int tile_len, const int sz);
00147 
00148 //! Take absolute value of the image
00149 void cuda_c_abs(float *src,const int tile_len, const int sz);
00150 
00151 //! Set the value of an entire image to a particular value
00152 void cuda_c_clear(float *src, const float val, const int tile_len, const int sz);
00153 
00154 //! Add device scalar inplace
00155 void cuda_c_inplaceAddScalar(float *ptr, const float *offset, const int tile_len, const int sz);
00156 
00157 //! Subtract device scalar inplace
00158 void cuda_c_inplaceSubtractScalar(float *ptr, const float *offset, const int tile_len, const int sz);
00159 
00160 //! Multiply device scalar inplace
00161 void cuda_c_inplaceMultiplyScalar(float *ptr, const float *offset, const int tile_len, const int sz);
00162 
00163 //! Divide device scalar inplace
00164 void cuda_c_inplaceDivideScalar(float *ptr, const float *offset, const int tile_len, const int sz);
00165 
00166 //! Add host scalar
00167 void cuda_c_inplaceAddHostScalar(float *ptr, const float val, const int tile_len, const int sz);
00168 
00169 //! Subtract host scalar
00170 void cuda_c_inplaceSubtractHostScalar(float *ptr, const float val, const int tile_len, const int sz);
00171 
00172 //! Multiply host scalar
00173 void cuda_c_inplaceMultiplyHostScalar(float *ptr, const float val, const int tile_len, const int sz);
00174 
00175 //! Divide host scalar
00176 void cuda_c_inplaceDivideHostScalar(float *ptr, const float val, const int tile_len, const int sz);
00177 
00178 //! Add images inplace
00179 void cuda_c_inplaceAddImages(float *im1, const float *im2, const int tile_len, const int sz);
00180 
00181 //! Subtract images inplace
00182 void cuda_c_inplaceSubtractImages(float *im1, const float *im2, const int tile_len, const int sz);
00183 
00184 //! Multiply images inplace
00185 void cuda_c_inplaceMultiplyImages(float *im1, const float *im2, const int tile_len, const int sz);
00186 
00187 //! Divide images inplace
00188 void cuda_c_inplaceDivideImages(float *im1, const float *im2, const int tile_len, const int sz);
00189 
00190 //! Add images
00191 void cuda_c_addImages(const float *im1, const float *im2, float *res, const int tile_len, const int sz);
00192 
00193 //! Subtract images
00194 void cuda_c_subtractImages(const float *im1, const float *im2, float *res, const int tile_len, const int sz);
00195 
00196 //! Multiply images
00197 void cuda_c_multiplyImages(const float *im1, const float *im2, float *res, const int tile_len, const int sz);
00198 
00199 //! Divide images
00200 void cuda_c_divideImages(const float *im1, const float *im2, float *res, const int tile_len, const int sz);
00201 
00202 //! Take the max of each pixel from the two input images as the output
00203 void cuda_c_takeMax(const float *im1, const float *im2, float *res, const int tile_len, const int sz);
00204 
00205 //! Add device scalar
00206 void cuda_c_addScalar(const float *im1, const float *im2, float *res, const int tile_len, const int sz);
00207 
00208 //! Subtract device scalar
00209 void cuda_c_subtractScalar(const float *im1, const float *im2, float *res, const int tile_len, const int sz);
00210 
00211 //! Multiply device scalar
00212 void cuda_c_multiplyScalar(const float *im1, const float *im2, float *res, const int tile_len, const int sz);
00213 
00214 //! Divide device scalar
00215 void cuda_c_divideScalar(const float *im1, const float *im2, float *res, const int tile_len, const int sz);
00216 
00217 //! Add host scalar
00218 void cuda_c_addHostScalar(const float *im1, const float val, float *res, const int tile_len, const int sz);
00219 
00220 //! Subtract host scalar
00221 void cuda_c_subtractHostScalar(const float *im1, const float val, float *res, const int tile_len, const int sz);
00222 
00223 //! Multiply host scalar
00224 void cuda_c_multiplyHostScalar(const float *im1, const float val, float *res, const int tile_len, const int sz);
00225 
00226 //! Divide host scalar
00227 void cuda_c_divideHostScalar(const float *im1, const float val, float *res, const int tile_len, const int sz);
00228 
00229 //! Get the global min of an image
00230 void cuda_c_getMin(const float *src, float *dest, float *buf, const int tile_len, const int sz);
00231 
00232 //! Get the global max of an image
00233 void cuda_c_getMax(const float *src, float *dest, float *buf, const int tile_len, const int sz);
00234 
00235 //! Get the global avg of an image
00236 void cuda_c_getAvg(const float *src, float *dest, float *buf, const int tile_len, const int sz);
00237 
00238 //! Get the sum of all of the pixels of the image
00239 void cuda_c_getSum(const float *src, float *dest, float *buf, const int tile_len, const int sz);
00240 
00241 //! Square each pixel
00242 void cuda_c_squared(const float *im, float *res, const int tile_len, const int sz);
00243 
00244 //! Take square root of each pixel
00245 void cuda_c_sqrt(const float *im, float *res, const int tile_len, const int sz);
00246 
00247 //! Get the quad energy
00248 void cuda_c_quadEnergy(const float *real, const float *imag, float *out, int tile_len, int sz);
00249 
00250 //! Progressive attenuation of the border of an image
00251 void cuda_c_inplaceAttenuateBorders(float *im, int borderSize, int tile_len, int w, int h);
00252 
00253 //! Find the index of the largest value of an image
00254 void cuda_c_findMax(const float *src, float *buf, int *loc, const int tile_len, const int sz);
00255 
00256 //! Find the index of the lowest value of an image
00257 void cuda_c_findMin(const float *src, float *buf, int *loc, const int tile_len, const int sz);
00258 
00259 //! Generate a difference of Gaussian filter as parameterized by HMAX
00260 void cuda_c_dogFilterHmax(float *dest, const float theta, const float gamma, const int size, const float div, const int tile_width, const int tile_height);
00261 
00262 //! Generate a difference of Gaussian filter
00263 void cuda_c_dogFilter(float *dest, float theta, float stddev, int half_size, int size, int tile_width, int tile_height);
00264 
00265 //! Generate gabor kernel
00266 void cuda_c_gaborFilter3(float *kern, const float major_stddev, const float minor_stddev,
00267                          const float period, const float phase,
00268                          const float theta, const int size, const int tile_len, const int sz);
00269 
00270 //! Generate a 1D Gaussian kernel
00271 void cuda_c_gaussian(float *res, float c, float sig22, int hw, int tile_len, int sz);
00272 
00273 //! Run 2d oriented filter over image
00274 void cuda_c_orientedFilter(const float *src, float *re, float *im, const float kx, const float ky, const float intensity, const int w, const int h, const int tile_width);
00275 
00276 //! Compute abs(Center-Surround)
00277 void cuda_c_centerSurroundAbs(const float *center, const float *surround, float *res, int lw, int lh, int sw, int sh, int tile_width );
00278 
00279 //! Compute rectified(Center-Surround)
00280 void cuda_c_centerSurroundClamped(const float *center, const float *surround, float *res, int lw, int lh, int sw, int sh, int tile_width );
00281 
00282 //! Compute pos(Center-Surround) and neg(Center-Surround) separately to maintain direction
00283 void cuda_c_centerSurroundDirectional(const float *center, const float *surround, float *pos, float *neg, int lw, int lh, int sw, int sh, int tile_width );
00284 
00285 //! Compute abs(Center-Surround) with an attenuated border
00286 void cuda_c_centerSurroundAbsAttenuate(const float *center, const float *surround, float *res, int lw, int lh, int sw, int sh, int attBorder, int tile_width, int tile_height);
00287 
00288 //! Do local max over a window of activation
00289 void cuda_c_spatialPoolMax(const float *src, float *res, float *buf1, float *buf2, const int src_w_in, const int src_h_in, const int skip_w_in, const int skip_h_in,
00290                            const int reg_w_in, const int reg_h_in, int tile_width_in, int tile_height_in);
00291 
00292 //! Seed the random number generator -- MANDATORY!
00293 void cuda_c_seedMT(unsigned int seed);
00294 
00295 //! Get a bank of random numbers
00296 void cuda_c_randomMT(float *d_Random, int numVals, int tile_len);
00297 
00298 //! Add background noise to the image
00299 void cuda_c_inplaceAddBGnoise2(float *in, float *rnd, const int brd_siz, const float range, int w, int h, int tile_len);
00300 
00301 //! Hmax image energy normalized convolution
00302 void cuda_c_convolveHmaxHelper(float *res, const float *src, const int src_w, const int src_h,
00303                                const float *f, const int Nx, const int Ny, const int tile_width, const int tile_height);
00304 
00305 //! Zero boundary convolution
00306 void cuda_c_convolveZeroHelper(float *res, const float *src, const int src_w, const int src_h,
00307                                const float *f, const int Nx, const int Ny, const int tile_width, const int tile_height);
00308 
00309 //! Clean boundary convolution
00310 void cuda_c_convolveCleanHelper(float *res, const float *src, const int src_w, const int src_h,
00311                                 const float *f, const int Nx, const int Ny, const int tile_width, const int tile_height);
00312 
00313 //! Optimized Hmax image energy normalized convolution
00314 void cuda_c_convolveHmaxHelperOptimized(float *res, const float *src, const int src_w, const int src_h,
00315                                         const float *f, const int Nx, const int Ny, const int tile_width, const int tile_height);
00316 
00317 //! Optimized zero boundary convolution
00318 void cuda_c_convolveZeroHelperOptimized(float *res, const float *src, const int src_w, const int src_h,
00319                                         const float *f, const int Nx, const int Ny, const int tile_width, const int tile_height);
00320 
00321 //! Optimized convolution
00322 void cuda_c_optConvolve(float *res, const float *src, const int src_w, const int src_h,
00323                         const float *f, const int fil_w, const int fil_h, const int tile_width, const int tile_height);
00324 
00325 //! Zero boundary X dimension separable filter convolution
00326 void cuda_c_xFilterZero(float *res, const float *src, const int src_w, const int src_h, const float *f, const int hfs, const int share_len, const int tile_len);
00327 
00328 //! Clean boundary X dimension separable filter convolution
00329 void cuda_c_xFilterClean(float *res, const float *src, const int src_w, const int src_h, const float *f, const int hfs, const int share_len, const int tile_len);
00330 
00331 //! Replicated boundary X dimension separable filter convolution
00332 void cuda_c_xFilterReplicate(float *res, const float *src, const int src_w, const int src_h, const float *f, const int hfs, const int share_len, const int tile_len);
00333 
00334 //! Zero boundary Y dimension separable filter convolution
00335 void cuda_c_yFilterZero(float *res, const float *src, const int src_w, const int src_h, const float *f, const int hfs, const int share_len, const int tile_len);
00336 
00337 //! Clean boundary Y dimension separable filter convolution
00338 void cuda_c_yFilterClean(float *res, const float *src, const int src_w, const int src_h, const float *f, const int hfs, const int share_len, const int tile_len);
00339 
00340 //! Replicated boundary Y dimension separable filter convolution
00341 void cuda_c_yFilterReplicate(float *res, const float *src, const int src_w, const int src_h, const float *f, const int hfs, const int share_len, const int tile_len);
00342 
00343 //! Optimized version of zero boundary X dimension separable filter, limited to only a certain size
00344 void cuda_c_optXFilterZero(float *res, const float *src, const int src_w, const int src_h, const float *f, const int hfs, const int tile_len);
00345 
00346 //! Optimized version of zero boundary Y dimension separable filter, limited to only a certain size
00347 void cuda_c_optYFilterZero(float *res, const float *src, const int src_w, const int src_h, const float *f, const int hfs, const int tile_len);
00348 
00349 //! Optimized version of clean boundary X dimension separable filter, limited to only a certain size
00350 void cuda_c_optXFilterClean(float *res, const float *src, const int src_w, const int src_h, const float *f, const int hfs, const int tile_len);
00351 
00352 //! Optimized version of clean boundary Y dimension separable filter, limited to only a certain size
00353 void cuda_c_optYFilterClean(float *res, const float *src, const int src_w, const int src_h, const float *f, const int hfs, const int tile_len);
00354 
00355 //! Optimized version of replicate boundary X dimension separable filter, limited to only a certain size
00356 void cuda_c_optXFilterReplicate(float *res, const float *src, const int src_w, const int src_h, const float *f, const int hfs, const int tile_len);
00357 
00358 //! Optimized version of replicate boundary Y dimension separable filter, limited to only a certain size
00359 void cuda_c_optYFilterReplicate(float *res, const float *src, const int src_w, const int src_h, const float *f, const int hfs, const int tile_len);
00360 
00361 
00362 //! Debayer the image
00363 void cuda_2_debayer(float *src,float3_t *dptr,int w, int h, int tile_width, int tile_height);
00364 
00365 //! Crop the image
00366 void cuda_c_crop(const float *src, float *res, int srcw, int srch, int startx, int starty, int endx, int endy, int maxx,int maxy, int tile_width, int tile_height);
00367 
00368 //! Translate image by deltax, deltay
00369 void cuda_c_shiftImage(const float *src, float *dst, int w, int h, float deltax, float deltay, int tile_width, int tile_height);
00370 
00371 // Paste an image onto an existing image
00372 void cuda_c_inplacePaste(float *dst, const float *img, int w, int h, int iw, int ih, int dx, int dy, int tile_width, int tile_height);
00373 
00374 // Paste an RGB image onto an existing image
00375 void cuda_c_inplacePasteRGB(float3_t *dst, const float3_t *img, int w, int h, int iw, int ih, int dx, int dy, int tile_width, int tile_height);
00376 
00377 // Overlay an image onto an existing image, only overwite pixels if overlaid image pixel is nonzero
00378 void cuda_c_inplaceOverlay(float *dst, const float *img, int w, int h, int iw, int ih, int dx, int dy, int tile_width, int tile_height);
00379 
00380 // Overlay an RGB image onto an existing image, only overwite pixels if overlaid image pixel is nonzero
00381 void cuda_c_inplaceOverlayRGB(float3_t *dst, const float3_t *img, int w, int h, int iw, int ih, int dx, int dy, int tile_width, int tile_height);
00382 
00383 // Calculate an inertia map
00384 void cuda_c_inertiaMap(float_t *dst, float s, float r_inv, int px, int py, int tile_width, int tile_height, int w, int h);
00385 
00386 // Calculate an inhibition map taking into account existing inhibition
00387 void cuda_c_inhibitionMap(float *dst, float factorOld, float factorNew, float radius, int px, int py, int tile_width, int tile_height, int w, int h);
00388 
00389 #ifdef __cplusplus
00390 }
00391 #endif
00392 
00393 // ######################################################################
00394 /* So things look consistent in everyone's emacs... */
00395 /* Local Variables: */
00396 /* mode: c++ */
00397 /* indent-tabs-mode: nil */
00398 /* End: */
00399 
00400 
00401 #endif
Generated on Sun May 8 08:40:37 2011 for iLab Neuromorphic Vision Toolkit by  doxygen 1.6.3