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
|
// Compute 3D shape
Space3D<double,1> space;
if(cfg.error1)
space=GD_projection_by_sumOut(cameras,silhouettes,cfg.sizeX,cfg.sizeY,cfg.sizeZ,cfg.voxel_size,offset,cfg.e_lambda,0.03,cfg.max_it,cfg.dt,cfg.alpha);
else
space=GDok_dtOpt_partFixed_SPOTsphOut_fasterN(cameras,silhouettes,cfg.sizeX,cfg.sizeY,cfg.sizeZ,cfg.voxel_size,offset,cfg.e_lambda,0.03,cfg.max_it,cfg.dt,cfg.alpha);
Volume<double> shape(space.size_x(),space.size_y(),space.size_z());
shape=space.volume();
// Write volume in a binary file
FILE *fw=NULL;
double val;
fw=fopen(cfg.out_file.c_str(),"w+");
if(fw==NULL)
cout << "Not enough memory file\n" << endl;
int nz=0,no=0;
for(z=0; z < space.size_z(); z++)
for(y=0; y < space.size_y(); y++)
for(x=0; x < space.size_x(); x++)
{
val=shape[x][y][z];
fwrite(&val,sizeof(double),1,fw);
if(val==1) no++;
if(val==0) nz++;
if(space.volume()[x][y][z]>0.5) space.volume()[x][y][z]=1;
else space.volume()[x][y][z]=0;
}
cout << "Number of voxels: " << space.size_z()*space.size_y()*space.size_x() << " to1: " << no << " to0: " << nz << endl;
fclose(fw);
// Write projection images
write_projections(space,cameras);
return 0;
}
|