cudaSift_gold.c

00001 ////////////////////////////////////////////////////////////////////////////////
00002 // Reference row convolution filter
00003 ////////////////////////////////////////////////////////////////////////////////
00004 extern "C" void ConvRowCPU(float *h_Result, float *h_Data, float *h_Kernel,
00005                            int dataW, int dataH, int kernelR)
00006 {
00007   int x, y, k, d;
00008   float sum;
00009   for (y=0;y<dataH;y++)
00010     for (x=0;x<dataW;x++) {
00011       sum = 0;
00012       for (k=-kernelR;k<=kernelR;k++) {
00013         d = x + k;
00014         d = (d<0 ? 0 : d);
00015         d = (d>=dataW ? dataW-1 : d);
00016         sum += h_Data[y*dataW + d] * h_Kernel[kernelR - k];
00017       }
00018       h_Result[y*dataW + x] = sum;
00019     }
00020 }
00021 
00022 ////////////////////////////////////////////////////////////////////////////////
00023 // Reference column convolution filter
00024 ////////////////////////////////////////////////////////////////////////////////
00025 extern "C" void ConvColCPU(float *h_Result, float *h_Data, float *h_Kernel,
00026                            int dataW, int dataH, int kernelR)
00027 {
00028   int x, y, k, d;
00029   float sum;
00030   for (y=0;y<dataH;y++)
00031     for (x=0;x<dataW;x++) {
00032       sum = 0;
00033       for (k=-kernelR;k<=kernelR;k++) {
00034         d = y + k;
00035         d = (d<0 ? 0 : d);
00036         d = (d>=dataH ? dataH-1 : d);
00037         sum += h_Data[d*dataW + x] * h_Kernel[kernelR - k];
00038       }
00039       h_Result[y*dataW + x] = sum;
00040     }
00041 }
Generated on Sun May 8 08:40:37 2011 for iLab Neuromorphic Vision Toolkit by  doxygen 1.6.3