00001 #include <Segmentation.h> 00002 #include <SegmentationModule/RegularizationModule.h> 00003 #include <SegmentationModule/GeodesicActiveContourModule.h> 00004 00007 int main(int argc, char* argv[]) 00008 { 00009 using namespace Images; 00010 using namespace levelset; 00011 using namespace segmentation; 00012 00013 BaseImage<2, float> image; 00014 std::ifstream f("image/head3.inr"); 00015 f >> format("inrimage") >> image; 00016 Globals::normalize(image, 0.0f, 250.0f); 00017 00018 FastMarchingInitializer<2,float> init; // Fast Marching Initializer 00019 LevelSet<2,float> phi(image.shape(), (double) 2.0); // Level Set 00020 Segmentation<2,float> segm(&phi, &init, &image); // Segmentation 00021 00022 // Initalization of the level set 00023 phi.init_border(120, init); 00024 00025 // Initialization of the module 00026 // IMPORTANT Do not add a regularization term using the geodesic active contour module 00027 GeodesicActiveContourModule<2,float,float> gac(&image, 1.f, -1.f , 2); // parameters : image, weight, balloon, smooth 00028 00029 gac.balloon() = 2; 00030 00031 segm.add_module(gac); 00032 00033 00034 // launch the segmentation 00035 Segmentation<2,float>::RGBPixel neg(215,152,0); 00036 Segmentation<2,float>::RGBPixel pos(255,252,0); 00037 00038 timeval _time; 00039 00040 std::ostringstream name; 00041 name.str(""); 00042 name << "mkdir CVPR/"; 00043 system (name.str().c_str()); 00044 name.str(""); 00045 name << "mkdir CVPR/gaussian_cortex"; 00046 system (name.str().c_str()); 00047 name.str(""); 00048 name << "CVPR/gaussian_cortex/geodesic"; 00049 Globals::initChrono(_time); 00050 00051 segm.segment(2000, name.str().c_str(), neg, pos); 00052 00053 Globals::printChrono("\n => Gaussian : ", _time); 00054 Globals::initChrono(_time); 00055 00056 std::cout << "OK" << std::endl; 00057 00058 00059 return 0; 00060 }