a744d027
Laila Saadatifard
upload the ivote3...
|
1
|
|
c9aba18a
Laila Saadatifard
ivote3 on the GPU...
|
2
3
|
#include "gaussian_blur3.cuh"
#include "gradient3.cuh"
|
f12505fb
Laila Saadatifard
upload the ivote ...
|
4
|
#include "mag3.cuh"
|
a744d027
Laila Saadatifard
upload the ivote3...
|
5
|
#include "vote3_atomic_aabb.cuh"
|
1f55a874
Laila Saadatifard
upload the fixed ...
|
6
|
#include "update_dir3_aabb.cuh"
|
f12505fb
Laila Saadatifard
upload the ivote ...
|
7
|
#include "local_max3.cuh"
|
c9aba18a
Laila Saadatifard
ivote3 on the GPU...
|
8
9
|
|
2558ee86
Laila Saadatifard
updating ivote3 t...
|
10
|
void ivote3(float* img, float sigma[], float phi, float d_phi, unsigned int r[],
|
f12505fb
Laila Saadatifard
upload the ivote ...
|
11
12
|
int iter, float t, unsigned int conn[], unsigned int x, unsigned int y, unsigned int z){
|
94d437dd
Laila Saadatifard
ivote3 code compi...
|
13
|
|
c986ebb7
Laila Saadatifard
fix ivote3 to work
|
14
|
cudaSetDevice(0);
|
1f55a874
Laila Saadatifard
upload the fixed ...
|
15
16
|
unsigned int bytes = x * y * z * sizeof(float); // compute the number of bytes in the input data
|
f12505fb
Laila Saadatifard
upload the ivote ...
|
17
|
|
1f55a874
Laila Saadatifard
upload the fixed ...
|
18
|
float* gpuI0; //assign memory on gpu for the input data
|
f12505fb
Laila Saadatifard
upload the ivote ...
|
19
|
cudaMalloc(&gpuI0, bytes);
|
1f55a874
Laila Saadatifard
upload the fixed ...
|
20
|
cudaMemcpy(gpuI0, img, bytes, cudaMemcpyHostToDevice); //copy the image data to the GPU.
|
f12505fb
Laila Saadatifard
upload the ivote ...
|
21
|
|
1f55a874
Laila Saadatifard
upload the fixed ...
|
22
23
|
gpu_gaussian_blur3<float>(gpuI0, sigma, x, y, z); //call the blurring function from the gpu.
|
f12505fb
Laila Saadatifard
upload the ivote ...
|
24
25
|
cudaDeviceSynchronize();
|
1f55a874
Laila Saadatifard
upload the fixed ...
|
26
|
float* gpu_grad; //assign memory on the gpu for the gradient along the X, y, z.
|
c9aba18a
Laila Saadatifard
ivote3 on the GPU...
|
27
28
|
cudaMalloc(&gpu_grad, bytes*3);
|
2558ee86
Laila Saadatifard
updating ivote3 t...
|
29
|
gpu_gradient3<float>(gpu_grad, gpuI0, 1, x, y, z); //call the gradient function from the gpu.
|
f12505fb
Laila Saadatifard
upload the ivote ...
|
30
31
|
cudaFree(gpuI0);
|
f12505fb
Laila Saadatifard
upload the ivote ...
|
32
33
|
float* gpu_vote;
cudaMalloc(&gpu_vote, bytes);
|
c9aba18a
Laila Saadatifard
ivote3 on the GPU...
|
34
|
|
f12505fb
Laila Saadatifard
upload the ivote ...
|
35
36
37
38
|
float cos_phi = cos(phi);
//call the vote function.
for (int i = 0; i < iter; i++){
|
a744d027
Laila Saadatifard
upload the ivote3...
|
39
40
|
cudaMemset(gpu_vote, 0, bytes);
|
1f55a874
Laila Saadatifard
upload the fixed ...
|
41
|
gpu_vote3<float>(gpu_vote, gpu_grad, phi, cos_phi, r, x, y, z);
|
f12505fb
Laila Saadatifard
upload the ivote ...
|
42
|
cudaDeviceSynchronize();
|
a744d027
Laila Saadatifard
upload the ivote3...
|
43
44
|
//if (phi >= d_phi){
|
1f55a874
Laila Saadatifard
upload the fixed ...
|
45
|
gpu_update_dir3<float>(gpu_grad, gpu_vote, phi, cos_phi, r, x, y, z);
|
f12505fb
Laila Saadatifard
upload the ivote ...
|
46
47
48
|
cudaDeviceSynchronize();
phi = phi - d_phi;
cos_phi = cos(phi);
|
a744d027
Laila Saadatifard
upload the ivote3...
|
49
|
//}
|
f12505fb
Laila Saadatifard
upload the ivote ...
|
50
51
|
}
|
c9aba18a
Laila Saadatifard
ivote3 on the GPU...
|
52
|
|
2558ee86
Laila Saadatifard
updating ivote3 t...
|
53
|
cudaFree(gpu_grad);
|
46820b25
Laila Saadatifard
create an obj fil...
|
54
|
cudaMemcpy(img, gpu_vote, bytes, cudaMemcpyDeviceToHost);
|
2558ee86
Laila Saadatifard
updating ivote3 t...
|
55
|
|
f12505fb
Laila Saadatifard
upload the ivote ...
|
56
|
//allocate space on the gpu for the final detected cells.
|
46820b25
Laila Saadatifard
create an obj fil...
|
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
|
//float* gpu_output;
//cudaMalloc(&gpu_output, bytes);
////call the local max function
//gpu_local_max3<float>(gpu_output, gpu_vote, t, conn, x, y, z);
////copy the final result to the cpu.
//cudaMemcpy(center, gpu_output, bytes, cudaMemcpyDeviceToHost);
//
//
cudaFree(gpu_vote);
//cudaFree(gpu_output);
}
void lmax(float* out, float* in, float t, unsigned int conn[], unsigned int x, unsigned int y, unsigned int z){
unsigned int bytes = x * y * z * sizeof(float);
|
c986ebb7
Laila Saadatifard
fix ivote3 to work
|
75
|
cudaSetDevice(0);
|
a744d027
Laila Saadatifard
upload the ivote3...
|
76
|
|
1f55a874
Laila Saadatifard
upload the fixed ...
|
77
78
|
float* gpuV; //assign memory on gpu for the input data.
|
46820b25
Laila Saadatifard
create an obj fil...
|
79
80
|
cudaMalloc(&gpuV, bytes);
|
1f55a874
Laila Saadatifard
upload the fixed ...
|
81
|
cudaMemcpy(gpuV, in, bytes, cudaMemcpyHostToDevice); //copy the image data to the GPU.
|
46820b25
Laila Saadatifard
create an obj fil...
|
82
83
84
|
float* gpuOut;
cudaMalloc(&gpuOut, bytes);
|
f12505fb
Laila Saadatifard
upload the ivote ...
|
85
|
|
1f55a874
Laila Saadatifard
upload the fixed ...
|
86
|
gpu_local_max3<float>(gpuOut, gpuV, t, conn, x, y, z); //call the local max function
|
f12505fb
Laila Saadatifard
upload the ivote ...
|
87
|
|
1f55a874
Laila Saadatifard
upload the fixed ...
|
88
|
cudaMemcpy(out, gpuOut, bytes, cudaMemcpyDeviceToHost); //copy the final result to the cpu.
|
f12505fb
Laila Saadatifard
upload the ivote ...
|
89
|
|
46820b25
Laila Saadatifard
create an obj fil...
|
90
91
|
cudaFree(gpuV);
cudaFree(gpuOut);
|
a744d027
Laila Saadatifard
upload the ivote3...
|
92
|
}
|