Commit 5343a315a83fba1ddc129f4fa8345bd5945c82cf
1 parent
aa1bc80d
make changes to image_contour_detection.h
Showing
3 changed files
with
10 additions
and
13 deletions
Show diff stats
stim/cuda/array_add.cuh
... | ... | @@ -28,7 +28,7 @@ namespace stim{ |
28 | 28 | int threads = stim::maxThreadsPerBlock(); |
29 | 29 | |
30 | 30 | //calculate the number of blocks |
31 | - int blocks = N / threads + (N%threads == 0 ? 0:1); | |
31 | + int blocks = N / threads + 1; | |
32 | 32 | |
33 | 33 | //call the kernel to do the multiplication |
34 | 34 | cuda_add <<< blocks, threads >>>(ptr1, ptr2, sum, N); | ... | ... |
stim/cuda/conv2.cuh
... | ... | @@ -13,7 +13,7 @@ namespace stim{ |
13 | 13 | |
14 | 14 | template<typename T> |
15 | 15 | //__global__ void cuda_conv2(T* img, T* mask, T* copy, cudaTextureObject_t texObj, unsigned int w, unsigned int h, unsigned M){ |
16 | - __global__ void cuda_conv2(T* img, T* mask, T* copy, cudaTextureObject_t texObj, unsigned int w, unsigned int h, unsigned M){ | |
16 | + __global__ void cuda_conv2(T* img, T* mask, T* copy, cudaTextureObject_t texObj, unsigned int w, unsigned int h, unsigned int M){ | |
17 | 17 | |
18 | 18 | |
19 | 19 | //the radius of mask |
... | ... | @@ -35,7 +35,7 @@ namespace stim{ |
35 | 35 | //copy[idx] = tex2D<float>(texObj, i+100, j+100); |
36 | 36 | //return; |
37 | 37 | |
38 | - //tex2D<float>(texObj, i, j); | |
38 | + tex2D<float>(texObj, (float)i/w, (float)j/h); | |
39 | 39 | |
40 | 40 | //allocate memory for result |
41 | 41 | T sum = 0; |
... | ... | @@ -54,7 +54,7 @@ namespace stim{ |
54 | 54 | |
55 | 55 | //T temp = img[y * w + x] * mask[yy * M + xx]; |
56 | 56 | //sum += img[y * w + x] * mask[yy * M + xx]; |
57 | - sum += tex2D<T>(texObj, x, y) * 1.0;//mask[yy * M + xx]; | |
57 | + sum += tex2D<T>(texObj, (float)x/w, (float)y/h) * mask[yy * M + xx]; | |
58 | 58 | } |
59 | 59 | } |
60 | 60 | copy[idx] = sum; |
... | ... | @@ -89,11 +89,11 @@ namespace stim{ |
89 | 89 | // Specify texture object parameters |
90 | 90 | struct cudaTextureDesc texDesc; //create a texture descriptor |
91 | 91 | memset(&texDesc, 0, sizeof(texDesc)); //set all values in the texture descriptor to zero |
92 | - texDesc.addressMode[0] = cudaAddressModeMirror; //use wrapping (around the edges) | |
93 | - texDesc.addressMode[1] = cudaAddressModeMirror; | |
92 | + texDesc.addressMode[0] = cudaAddressModeClamp; //use wrapping (around the edges) | |
93 | + texDesc.addressMode[1] = cudaAddressModeClamp; | |
94 | 94 | texDesc.filterMode = cudaFilterModePoint; //use linear filtering |
95 | 95 | texDesc.readMode = cudaReadModeElementType; //reads data based on the element type (32-bit floats) |
96 | - texDesc.normalizedCoords = 0; //not using normalized coordinates | |
96 | + texDesc.normalizedCoords = 1; //using normalized coordinates | |
97 | 97 | |
98 | 98 | // Create texture object |
99 | 99 | cudaTextureObject_t texObj = 0; | ... | ... |
stim/image/image_contour_detection.h
1 | -//#include <stim/image/image.h> | |
2 | -//#include <cmath> | |
3 | -//#include <stim/visualization/colormap.h> | |
4 | 1 | |
5 | -stim::image<float> gaussian_derivative_filter_odd(stim::image<float> image, float sigma, unsigned int sigma_n, unsigned int winsize, float theta, unsigned int w, unsigned int h); | |
6 | -stim::image<float> func_mPb_theta(stim::image<float> lab, float theta, unsigned int w, unsigned int h); | |
7 | -stim::image<float> func_mPb(stim::image<float> lab, unsigned int theta_n, unsigned int w, unsigned int h); | |
8 | 2 | \ No newline at end of file |
3 | +stim::image<float> gaussian_derivative_filter_odd(stim::image<float> image, int r, unsigned int sigma_n, float theta); | |
4 | +stim::image<float> func_mPb_theta(stim::image<float> img, float theta, int* r, float* alpha, int s); | |
5 | +stim::image<float> func_mPb(stim::image<float> img, unsigned int theta_n, int* r, float* alpha, int s); | |
9 | 6 | \ No newline at end of file | ... | ... |