#include #include #include #include #include #include #include #include #include #define pi 3.14159 #define M_PI 3.14159 #include #include #include #include //#include //#include //#include /*void test_3(float* gpu_out, float* gpu_grad, float rmax, float phi, int n, int x, int y, int z); int main(){ int n=20; float rmax; float phi_deg; float phi; rmax=4; phi_deg = 15; phi = phi_deg * pi/180; int x,y,z; x=y=z=1; unsigned int size = x*y*z*sizeof (float); float* cpu_grad = (float*) malloc(3*size); float* gpu_grad; cudaMalloc(&gpu_grad, 3*size); cpu_grad[0]=1; cpu_grad[1]=0; cpu_grad[2]=-0.5; cudaMemcpy(gpu_grad, cpu_grad, 3*size, cudaMemcpyHostToDevice); float* cpu_out = (float*) malloc(3*size*(n+1)); float* gpu_out; cudaMalloc(&gpu_out, 3*size*(n+1)); test_3(gpu_out, gpu_grad, rmax, phi, n, x, y, z); cudaMemcpy(cpu_out, gpu_out, 3*size*(n+1), cudaMemcpyDeviceToHost); std::ofstream list("circle_check_cuda1.txt"); if (list.is_open()){ for (int j=0; j<=n; ++j) list << cpu_out[3*j] << '\t' << cpu_out[3*j +1] << '\t' << cpu_out[3*j + 2] << '\n'; } list.close(); */ /* int n=10; stim::circle cir; float* c0= (float*) malloc(3*sizeof(float)); c0[0] =-4; c0[1]=0; c0[2] = 3; stim::vec3 c(c0[0],c0[1],c0[2]); float len = c.len(); stim::vec3 norm(c0[0]/len,c0[1]/len,c0[2]/len); std::cout<< len << '\n'; std::cout<< norm << '\n'; cir.center(c); cir.normal(norm); cir.scale(2); stim::vec3 out = cir.p(45); std::vector> out2 = cir.getPoints(n); std::cout<< out << '\n'; std::cout <>::const_iterator i = out2.begin(); i != out2.end(); ++i) std::cout << *i << '\n'; std::ofstream list("circle_check.txt"); if (list.is_open()){ for (std::vector>::const_iterator j = out2.begin(); j != out2.end(); ++j) list << *j << '\n'; } list.close(); std::cin >> n; } */ void ivote3(float* img, float std[], float anisotropy, float phi, float d_phi, unsigned int r[], int iter, float t, unsigned int conn[], unsigned int x, unsigned int y, unsigned int z); void lmax(float* center, float* vote, float t1, unsigned int conn[], unsigned int x, unsigned int y, unsigned int z); void invert_data(float* cpuI, unsigned int x, unsigned int y, unsigned int z){ for(int ix = 0; ix < x; ix++){ for (int iy = 0; iy < y; iy++){ for (int iz = 0; iz < z; iz++){ int idx = iz * x * y + iy * x + ix; cpuI[idx] = 255 - cpuI[idx]; } } } } int main(int argc, char** argv){ cudaDeviceProp prop; int count; cudaGetDeviceCount(&count); //printf("cudadevicecount: %i\n", count); for (int i=0; iimgrad3; //imgrad3.set_interleaved3(cpu_out, 128,128,128,3); //std::ofstream fgx("syn/gx-128.vol", std::ofstream::out | std::ofstream::binary); //fgx.write((char*)imgrad3.channel(0).data(), bytes); //fgx.close(); //write the output file. //for (int t0=0; t0<=5000; t0+=100){ // float t1 = t0; int t0 = t; lmax(cpu_out, cpuI, t, conn, x, y, z); //std::ofstream fo("shared2D-v8/" + OutName.str(), std::ofstream::out | std::ofstream::binary); std::ofstream fo( OutName.str()+std::to_string(t0)+".vol", std::ofstream::out | std::ofstream::binary); fo.write((char*)cpu_out, bytes); fo.close(); // creat a file for saving the list centers //std::ofstream list("shared2D-v8/" + OutName.str()+std::to_string(t0)+".obj"); //// set the number of detected cells to zero. //int nod = 0; //if (list.is_open()){ // for (int iz=0; iz