From 5343a315a83fba1ddc129f4fa8345bd5945c82cf Mon Sep 17 00:00:00 2001 From: Tianshu Cheng Date: Fri, 11 Sep 2015 17:15:31 -0500 Subject: [PATCH] make changes to image_contour_detection.h --- stim/cuda/array_add.cuh | 2 +- stim/cuda/conv2.cuh | 12 ++++++------ stim/image/image_contour_detection.h | 9 +++------ 3 files changed, 10 insertions(+), 13 deletions(-) diff --git a/stim/cuda/array_add.cuh b/stim/cuda/array_add.cuh index a05353c..2e2a733 100644 --- a/stim/cuda/array_add.cuh +++ b/stim/cuda/array_add.cuh @@ -28,7 +28,7 @@ namespace stim{ int threads = stim::maxThreadsPerBlock(); //calculate the number of blocks - int blocks = N / threads + (N%threads == 0 ? 0:1); + int blocks = N / threads + 1; //call the kernel to do the multiplication cuda_add <<< blocks, threads >>>(ptr1, ptr2, sum, N); diff --git a/stim/cuda/conv2.cuh b/stim/cuda/conv2.cuh index a40fdd0..e720a04 100644 --- a/stim/cuda/conv2.cuh +++ b/stim/cuda/conv2.cuh @@ -13,7 +13,7 @@ namespace stim{ template //__global__ void cuda_conv2(T* img, T* mask, T* copy, cudaTextureObject_t texObj, unsigned int w, unsigned int h, unsigned M){ - __global__ void cuda_conv2(T* img, T* mask, T* copy, cudaTextureObject_t texObj, unsigned int w, unsigned int h, unsigned M){ + __global__ void cuda_conv2(T* img, T* mask, T* copy, cudaTextureObject_t texObj, unsigned int w, unsigned int h, unsigned int M){ //the radius of mask @@ -35,7 +35,7 @@ namespace stim{ //copy[idx] = tex2D(texObj, i+100, j+100); //return; - //tex2D(texObj, i, j); + tex2D(texObj, (float)i/w, (float)j/h); //allocate memory for result T sum = 0; @@ -54,7 +54,7 @@ namespace stim{ //T temp = img[y * w + x] * mask[yy * M + xx]; //sum += img[y * w + x] * mask[yy * M + xx]; - sum += tex2D(texObj, x, y) * 1.0;//mask[yy * M + xx]; + sum += tex2D(texObj, (float)x/w, (float)y/h) * mask[yy * M + xx]; } } copy[idx] = sum; @@ -89,11 +89,11 @@ namespace stim{ // Specify texture object parameters struct cudaTextureDesc texDesc; //create a texture descriptor memset(&texDesc, 0, sizeof(texDesc)); //set all values in the texture descriptor to zero - texDesc.addressMode[0] = cudaAddressModeMirror; //use wrapping (around the edges) - texDesc.addressMode[1] = cudaAddressModeMirror; + texDesc.addressMode[0] = cudaAddressModeClamp; //use wrapping (around the edges) + texDesc.addressMode[1] = cudaAddressModeClamp; texDesc.filterMode = cudaFilterModePoint; //use linear filtering texDesc.readMode = cudaReadModeElementType; //reads data based on the element type (32-bit floats) - texDesc.normalizedCoords = 0; //not using normalized coordinates + texDesc.normalizedCoords = 1; //using normalized coordinates // Create texture object cudaTextureObject_t texObj = 0; diff --git a/stim/image/image_contour_detection.h b/stim/image/image_contour_detection.h index 1f82efb..2db9174 100644 --- a/stim/image/image_contour_detection.h +++ b/stim/image/image_contour_detection.h @@ -1,7 +1,4 @@ -//#include -//#include -//#include -stim::image gaussian_derivative_filter_odd(stim::image image, float sigma, unsigned int sigma_n, unsigned int winsize, float theta, unsigned int w, unsigned int h); -stim::image func_mPb_theta(stim::image lab, float theta, unsigned int w, unsigned int h); -stim::image func_mPb(stim::image lab, unsigned int theta_n, unsigned int w, unsigned int h); \ No newline at end of file +stim::image gaussian_derivative_filter_odd(stim::image image, int r, unsigned int sigma_n, float theta); +stim::image func_mPb_theta(stim::image img, float theta, int* r, float* alpha, int s); +stim::image func_mPb(stim::image img, unsigned int theta_n, int* r, float* alpha, int s); \ No newline at end of file -- libgit2 0.21.4