1 // =========================================================================
2 // @author Leonardo Florez Valencia
3 // @email florez-l@javeriana.edu.co
4 // =========================================================================
7 #include <tclap/CmdLine.h>
9 #include <fpa/Common/SliceBySliceRandomWalker.h>
10 #include "Functions.h"
12 // -------------------------------------------------------------------------
13 const unsigned int Dim = 3;
15 typedef unsigned char TLabel;
16 typedef itk::NumericTraits< TPixel >::RealType TScalar;
17 typedef itk::Image< TPixel, Dim > TImage;
18 typedef itk::Image< TLabel, Dim > TLabels;
19 typedef itk::Image< TScalar, Dim > TScalarImage;
21 // -------------------------------------------------------------------------
22 int main( int argc, char* argv[] )
24 typedef TCLAP::ValueArg< std::string > _TStringArg;
25 typedef TCLAP::ValueArg< TScalar > _TRealArg;
28 _TStringArg in( "i", "input", "Input image", true, "", "file" );
29 _TStringArg labels( "l", "labels", "Input labels", true, "", "file" );
30 _TStringArg vesselness( "v", "vesselness", "Input vesselness", true, "", "file" );
31 _TStringArg out( "o", "output", "Output image", true, "", "file" );
32 _TRealArg beta( "b", "beta", "Beta", false, 2.5, "value (2.5)" );
33 _TRealArg eps( "e", "epsilon", "Epsilon", false, 1e-5, "value (1e-5)" );
34 _TRealArg vThr( "t", "vthreshold", "Vesselness thresnold (%)", false, 5, "value (5)" );
37 TCLAP::CmdLine cmd( "FastRandomWalker", ' ', "1.0.0" );
42 cmd.add( vesselness );
45 cmd.parse( argc, argv );
47 catch( TCLAP::ArgException& err )
50 << "===============================" << std::endl
51 << "Error caught: " << std::endl
52 << err.error( ) << " " << err.argId( ) << std::endl
53 << "===============================" << std::endl
62 TImage::Pointer input_image;
63 CTBronchi::ReadImage( input_image, in.getValue( ) );
66 TLabels::Pointer input_labels;
67 CTBronchi::ReadImage( input_labels, labels.getValue( ) );
69 // Read input vesselness
70 TScalarImage::Pointer input_vesselness;
71 CTBronchi::ReadImage( input_vesselness, vesselness.getValue( ) );
74 typedef fpa::Common::SliceBySliceRandomWalker< TImage, TLabels, TScalarImage > TFilter;
75 TFilter::Pointer filter = TFilter::New( );
76 filter->SetInput( input_image );
77 filter->SetInputLabels( input_labels );
78 filter->SetInputVesselness( input_vesselness );
79 filter->SetBeta( beta.getValue( ) );
80 filter->SetVesselnessThreshold( vThr.getValue( ) );
81 filter->SetEpsilon( eps.getValue( ) );
82 double t = CTBronchi::MeasureTime( filter );
84 << "SliceBySliceRandomWalker executed in "
85 << t << " s" << std::endl;
88 CTBronchi::WriteImage( filter->GetOutput( ), out.getValue( ) );
90 catch( std::exception& err )
93 << "===============================" << std::endl
94 << "Error caught: " << std::endl
95 << err.what( ) << std::endl
96 << "===============================" << std::endl