Jerome Piovano

Research in Medical Imaging and Computer Vision

2D_Parzen.C

Parzen Region Segmentation of a 2D Image

00001 #include <Segmentation.h>
00002 #include <SegmentationModule/RegularizationModule.h>
00003 #include <SegmentationModule/ParzenRegionModule.h>
00004 
00007 int main(int argc, char* argv[])
00008 {       
00009         using namespace Images;
00010         using namespace levelset;
00011         using namespace segmentation;
00012 
00013         // image to segment
00014         BaseImage<2, float> image;
00015         std::ifstream f("image/head3.inr");
00016         //std::ifstream f("image/last.inr");
00017         f >> format("inrimage") >> image;
00018         Globals::normalize(image, 0.0f, 250.0f);
00019 
00020         // initialization of the segmentations objects
00021         FastMarchingInitializer<2,float> init;                               // Fast Marching Initializer
00022         LevelSet<2,float>                phi(image.shape(), (double) 2.0);   // Level Set of band thickness = 2
00023         Segmentation<2,float>            segm(&phi, &init, &image);          // Segmentation
00024 
00025         // Initalization of the level set
00026         //phi.init_small_spheres(10, 30, init);    // parameters : radius, windows
00027          phi.init_small_spheres(10, 25, init);
00028 
00029         // initialization of the modules
00030         RegularizationModule<2,float>      regul(1.f);                // parameters : weight
00031         ParzenRegionModule<2,float,float>  parzen(&image, 1.f, 20);   // parameters : image, weight, variance of the kernel
00032 
00033         segm.add_module(regul);
00034         segm.add_module(parzen);
00035 
00036         // launch the segmentation
00037         Segmentation<2,float>::RGBPixel neg(215,152,0); 
00038         Segmentation<2,float>::RGBPixel pos(255,252,0); 
00039 
00040         timeval _time;
00041         Globals::initChrono(_time); 
00042 
00043         segm.segment(1000, "parzen_", neg, pos);
00044 
00045         Globals::printChrono("\n        => Parzen : ", _time);
00046         Globals::initChrono(_time); 
00047 
00048         std::cout << "OK" << std::endl;
00049 
00050         return 0;
00051 }

For further information, please contact Jerome Piovano - Last update 2008-02-08