00001 #include <Segmentation.h> 00002 00005 int main(int argc, char* argv[]) 00006 { 00007 using namespace Images; 00008 using namespace levelset; 00009 00010 #if 1 //2D 00011 00012 // binary image 00013 BaseImage<2, float> image; 00014 std::ifstream f("image/feuille.inr"); 00015 f >> format("inrimage") >> image; 00016 00017 // initialization 00018 FastMarchingInitializer<2,float> init; 00019 LevelSet<2,float> phi(image.shape(), -1); // parameters : shape, thickness 00020 00021 // distance map 00022 phi.init_image(image, init); 00023 00024 #if 0 // test the reinit_PDE 00025 for (LevelSet<2,float>::iterator<domain> ind=phi.begin() ; ind!=phi.end() ; ++ind ){ 00026 if (phi(ind)>0) phi(ind) = phi.thickness(); 00027 else if (phi(ind)<0) phi(ind) = -phi.thickness(); 00028 } 00029 00030 phi.reinit_PDE(300); 00031 #endif 00032 00033 std::ofstream f1("2D_DistanceMap.inr"); 00034 f1 << format("inrimage")<< phi; 00035 f1.close(); 00036 00037 #endif 00038 00039 #if 0 //3D 00040 00041 // binary image 00042 BaseImage<3, float> image; 00043 std::ifstream f("result_3D/localstats_phi_000442.inr"); 00044 f >> format("inrimage") >> image; 00045 00046 // initialization 00047 FastMarchingInitializer<3,float> init; 00048 LevelSet<3,float> phi(image.shape(), -1); // parameters : shape, thickness 00049 00050 // distance map 00051 phi.init_image(image, init); 00052 00053 std::ofstream f1("3D_DistanceMap.inr"); 00054 f1 << format("inrimage")<< phi; 00055 f1.close(); 00056 00057 #endif 00058 }