]> Creatis software - FrontAlgorithms.git/blob - appli/CTBronchi/RandomWalker.h
0edb26d49e702a57847b2ac0e0310ee5fc983187
[FrontAlgorithms.git] / appli / CTBronchi / RandomWalker.h
1 // =========================================================================
2 // @author Leonardo Florez Valencia
3 // @email florez-l@javeriana.edu.co
4 // =========================================================================
5 #ifndef __CTBronchi__RandomWalker__h__
6 #define __CTBronchi__RandomWalker__h__
7
8 #include <map>
9 #include <CTBronchi/Functions.h>
10 #include <fpa/Filters/Image/RandomWalker.h>
11 #include <fpa/Functors/Dijkstra/Image/Gaussian.h>
12
13 namespace CTBronchi
14 {
15   // -----------------------------------------------------------------------
16   template< class _TInputPtr, class _TOutputPtr, class _TLabelPtr >
17   void RandomWalker(
18     _TOutputPtr& output,
19     const _TInputPtr& input, const _TLabelPtr& labels,
20     std::map< std::string, std::string >& args
21     )
22   {
23     typedef typename _TInputPtr::ObjectType  _TInput;
24     typedef typename _TOutputPtr::ObjectType _TOutput;
25     typedef typename _TLabelPtr::ObjectType _TLabel;
26     typedef typename _TOutput::PixelType _TOutputPixel;
27     typedef fpa::Filters::Image::RandomWalker< _TInput, _TLabel, _TOutputPixel > _TRandomWalker;
28     typedef fpa::Functors::Dijkstra::Image::Gaussian< _TInput, _TOutputPixel > _TWeight;
29
30     typename _TWeight::Pointer weight = _TWeight::New( );
31     weight->SetAlpha( std::atof( args[ "random_walker_alpha" ].c_str( ) ) );
32     weight->SetBeta( std::atof( args[ "random_walker_beta" ].c_str( ) ) );
33
34     typename _TRandomWalker::Pointer rw = _TRandomWalker::New( );
35     rw->SetInputImage( input );
36     rw->SetInputLabels( labels );
37     rw->SetWeightFunction( weight );
38     double t = CTBronchi::MeasureTime( rw );
39     std::cout << "RandomWalker executed in " << t << " s" << std::endl;
40     output = rw->GetOutput( );
41     output->DisconnectPipeline( );
42   }
43
44 } // ecapseman
45
46 #endif // __CTBronchi__Functions__h__
47
48 // eof - $RCSfile$