main.cpp

Go to the documentation of this file.
00001 
00002 #include <cmath>
00003 #include <iostream>
00004 #include <sstream>
00005 #include <Volume.hpp>
00006 #include <Texture.hpp>
00007 
00008 std::string get_string(const int& k);
00009 
00010 
00011 int main(int argc,char *argv[])
00012 {
00013 
00014   std::cout<<"start "<<argv[0]<<" with "<<argc<<" arg"<<std::endl;
00015 
00016   try
00017   {
00018 
00019       //************************//
00020       //Load
00021       //************************//
00022       Volume vol=Volume::load_v4d("data/head_ct.4d");
00023       vol=vol.resampled_square(100);
00024       for(int k=0;k<2;++k)
00025           vol=vol.smoothed();
00026 
00027 
00028 
00029       //************************//
00030       //export slices
00031       //************************//
00032       std::vector<float> sx=vol.slice_x(vol.size_x()/2.0);
00033       Texture::export_ppm("output/slice_x.ppm",vol.size_y(),vol.size_z(),sx,sx,sx);
00034 
00035       std::vector<float> sy=vol.slice_y(vol.size_y()/2.0);
00036       Texture::export_ppm("output/slice_y.ppm",vol.size_x(),vol.size_z(),sy,sy,sy);
00037 
00038       std::vector<float> sz=vol.slice_z(vol.size_z()/2.0);
00039       Texture::export_ppm("output/slice_z.ppm",vol.size_x(),vol.size_y(),sz,sz,sz);
00040 
00041 
00042 
00043 
00044 
00045 
00046       //************************//
00047       //Integration
00048       //************************//
00049 
00050       //number of rotation steps
00051       int N=10;
00052       for(int counter=0;counter<N;++counter)
00053       {
00054           std::string number=get_string(counter);
00055 
00056           std::cout<<"export file "<<counter+1<<" / "<<N<<std::endl;
00057           double angle=static_cast<double>(counter)/static_cast<double>(N-1)*M_PI*2+M_PI/2.0;
00058           Volume vol2=vol.rotated_z(angle);
00059 
00060 
00061           //MIP
00062           std::vector<float> val=vol2.mip();
00063           Texture::export_ppm("output/mip_"+number+".ppm",vol.size_y(),vol.size_z(),val,val,val);
00064 
00065           //Ray Casting
00066           std::vector<std::vector<float> > val_couleur=vol2.ray_cast();
00067           Texture::export_ppm("output/ray_"+number+".ppm",vol.size_y(),vol.size_z(),val_couleur[0],val_couleur[1],val_couleur[2]);
00068       }
00069 
00070 
00071   }
00072   catch(const std::string& e)
00073   {
00074       std::cout<<"================================"<<std::endl;
00075       std::cout<<"Exception catch"<<std::endl;
00076       std::cout<<e<<std::endl;
00077   }
00078 
00079   return 0;
00080 }
00081 
00082 std::string get_string(const int& k)
00083 {
00084 
00085     std::stringstream stream_number;stream_number<<k;
00086     std::string number(stream_number.str());
00087 
00088     if(k<10)
00089         number="00"+number;
00090     else if(k<100)
00091         number="0"+number;
00092     return number;
00093 
00094 }

Generated on Sun Jan 24 21:30:26 2010 by  doxygen 1.6.1