Blame view

main.cpp 1.79 KB
76a0f6f9   Laila Saadatifard   first commit to i...
1
2
3
4
5
6
7
8
9
10
11
12
13
  #include <iostream>
  #include <fstream>
  #include <cuda_runtime.h>
  #include <stim/math/vector.h>
  #include <stim/parser/arguments.h>
  #include <stim/parser/filename.h>
  #include <stim/grids/image_stack.h>
  #include <stim/grids/grid.h>
  #include <stim/visualization/colormap.h>
  
  #define pi	3.14159
  
  
c9aba18a   Laila Saadatifard   ivote3 on the GPU...
14
  void gaussian_blur_conv3(float* blur, float* img, float std, unsigned int x, unsigned int y, unsigned int z);
76a0f6f9   Laila Saadatifard   first commit to i...
15
  
c9aba18a   Laila Saadatifard   ivote3 on the GPU...
16
  int main(){
76a0f6f9   Laila Saadatifard   first commit to i...
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
  
  	float sigma =5;
  
  	// load the imagestack from the given directory
  	std::string file_mask = "D:\\source\\ivote3\\data\\nissl\\*.png";
  	stim::image_stack<float> I;
  	unsigned int x =512;
  	unsigned int y =512;
  	unsigned int z =512;
  	unsigned int bytes = x*y*z* sizeof(float);
  	
  	stim::vec<unsigned int> R(x, y, z);
  
  	I.read("D:\\source\\ivote3\\data\\nissl\\nissl-rat.vol", 512, 512, 512, 1, 12);
  	//float test = I.get(128, 128, 128);
  	//std::cout<< test<<std::endl;
  	float* ptr0 = I.data();
  		
  	float* cpuI = (float*) malloc(512*512*512*sizeof(float));	
  	
  	memcpy (cpuI, ptr0, bytes);
  	std::ofstream outfile ("data\\original.vol");
  	outfile.write((char*)cpuI, 512*512*512);
  
c9aba18a   Laila Saadatifard   ivote3 on the GPU...
41
42
43
44
  	float* cpuIb = (float*) malloc(512*512*512*sizeof(float));	
  	gaussian_blur_conv3(cpuIb, cpuI, sigma, x, y, z);
  	std::ofstream blurfile ("data\\IBlur.vol");
  	blurfile.write((char*)cpuIb, 512*512*512);
76a0f6f9   Laila Saadatifard   first commit to i...
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
  	//int n = memcmp(cpuI, ptr0, bytes);
  	//std::cout << n << std::endl;
  	//std::cin >> n;
  
  	//multiply(cpuI, 10, x*y*z);
  	//int n = memcmp (cpuI, ptr0, bytes);
  	//std::cout << n << std::endl;
  	//std::fstream file2;
  	//file2.write((char*)cpuI, 512*512*512*sizeof(unsigned char));
  	//I.write("data\\volume1.raw");
  	//test = ptr0[128*128*128];
  	//std::cout<< test<<std::endl;
  	
  	//std::cin>> x;
  
  
  	//memset(I.data(), 0, 512*512*512);
  	//I.write("data\\volume.raw");
  	//I.save_images("data\\????.bmp");
  	
  
  
  
  	
  
  //			cudaDeviceReset();           
  }