-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.cpp
More file actions
158 lines (99 loc) · 4.78 KB
/
main.cpp
File metadata and controls
158 lines (99 loc) · 4.78 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
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
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
#include <iostream>
#include <arrayfire.h>
#include "src/MeshDataAF.h"
#include "src/SynImageClasses.hpp"
#include "src/GenerateTemplates.hpp"
#include "src/SynImagePar.hpp"
int main() {
af::info();
af::array test;
MeshDataAF<uint16_t> test_m;
SynImage test_syn_image;
Syn_gen_par syn_par;
std::string image_name = "test_sphere1";
syn_par.name = image_name;
syn_par.template_name = "sphere";
/////////////////////////////////////////
//////////////////////////////////////////
// SET UP THE DOMAIN SIZE
int x_num = 400;
int y_num = 400;
int z_num = 400;
///////////////////////////////////////////////////////////////////
//
// sampling properties
//voxel size
float voxel_size = .1;
float sampling_delta = .1;
test_syn_image.sampling_properties.voxel_real_dims[0] = voxel_size;
test_syn_image.sampling_properties.voxel_real_dims[1] = voxel_size;
test_syn_image.sampling_properties.voxel_real_dims[2] = voxel_size;
//sampling rate/delta
test_syn_image.sampling_properties.sampling_delta[0] = sampling_delta;
test_syn_image.sampling_properties.sampling_delta[1] = sampling_delta;
test_syn_image.sampling_properties.sampling_delta[2] = sampling_delta;
//real size of domain
float dom_size_y = y_num*sampling_delta;
float dom_size_x = x_num*sampling_delta;
float dom_size_z = z_num*sampling_delta;
test_syn_image.real_domain.set_domain_size(0, dom_size_y, 0, dom_size_x, 0, dom_size_z);
///////////////////////////////////////////////////////////////////
//PSF properties
test_syn_image.PSF_properties.real_sigmas[0] = .1;
test_syn_image.PSF_properties.real_sigmas[1] = .1;
test_syn_image.PSF_properties.real_sigmas[2] = .1;
test_syn_image.PSF_properties.I0 = 1/(pow(2*3.14159265359,1.5)*test_syn_image.PSF_properties.real_sigmas[0]*test_syn_image.PSF_properties.real_sigmas[1]*test_syn_image.PSF_properties.real_sigmas[2]);
test_syn_image.PSF_properties.cut_th = 0.01;
test_syn_image.PSF_properties.set_guassian_window_size();
test_syn_image.PSF_properties.type = "gauss";
///////////////////////////////////////////////////
//Noise properties
test_syn_image.noise_properties.gauss_var = 50;
test_syn_image.noise_properties.noise_type = "poisson";
////////////////////////////////////////////////////
// Global Transforms
float shift = 1000;
float background = shift;
test_syn_image.global_trans.const_shift = shift;
float max_dim = std::max(dom_size_y,std::max(dom_size_y,dom_size_z));
float min_grad = .5*shift/max_dim; //stop it going negative
float max_grad = 1.5*shift/max_dim;
Genrand_uni gen_rand;
test_syn_image.global_trans.grad_y = 0*gen_rand.rand_num(-min_grad,max_grad);
test_syn_image.global_trans.grad_x = 0*gen_rand.rand_num(-min_grad,max_grad);
test_syn_image.global_trans.grad_z = 0*gen_rand.rand_num(-min_grad,max_grad);
/////////////////////////////////////////////
// GENERATE THE OBJECT TEMPLATE
std::cout << "Generating Templates" << std::endl;
//generate a sphere to use
Object_template basic_sphere;
int sample_rate = 100;
float real_size = 5;
float density = 1000000;
generate_sphere_template(basic_sphere,sample_rate,real_size,density);
//add the basic sphere as the standard template
test_syn_image.object_templates.push_back(basic_sphere);
Real_object temp_obj;
//set the template id
temp_obj.template_id = 0;
int num_objects = 10;
float desired_I = sqrt(background)*30;
for (int q = 0; q < num_objects; q++) {
temp_obj.location[0] = gen_rand.rand_num(0,test_syn_image.real_domain.size[0] - real_size);
temp_obj.location[1] = gen_rand.rand_num(0,test_syn_image.real_domain.size[1] - real_size);
temp_obj.location[2] = gen_rand.rand_num(0,test_syn_image.real_domain.size[2] - real_size);
float obj_int = gen_rand.rand_num(1,10)*desired_I;
temp_obj.int_scale = (((test_syn_image.object_templates[temp_obj.template_id].real_deltas[0]*test_syn_image.object_templates[temp_obj.template_id].real_deltas[1]*test_syn_image.object_templates[temp_obj.template_id].real_deltas[2])*obj_int)/(test_syn_image.object_templates[temp_obj.template_id].max_sample*pow(test_syn_image.sampling_properties.voxel_real_dims[0],3)));
test_syn_image.real_objects.push_back(temp_obj);
}
////////////////////////////////////////////////////////////////////////////
//
//generate image
////////////////////////////////////////////////////////////////////////////
//
MeshDataAF<uint16_t> test_gen_image;
std::cout << "Generating Image" << std::endl;
test_syn_image.generate_syn_image(test_gen_image);
std::cout << "Done" << std::endl;
return 0;
}