1 // =========================================================================
2 // @author Leonardo Florez Valencia
3 // @email florez-l@javeriana.edu.co
4 // =========================================================================
7 #include <tclap/CmdLine.h>
9 #include "MoriLabelling.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< double > _TRealArg;
26 typedef TCLAP::ValueArg< TPixel > _TPixelArg;
29 _TStringArg in( "i", "input", "Input image", true, "", "file" );
30 _TStringArg labels( "l", "labels", "Input labels", true, "", "file" );
31 _TStringArg vesselness( "v", "vesselness", "Input vesselness", true, "", "file" );
32 _TStringArg out( "o", "output", "Output image", true, "", "file" );
33 _TRealArg vThr( "a", "vesselness_thr", "Vesselness threshold", false, 0.05, "value (0.05)" );
34 _TPixelArg uThr( "u", "upper_thr", "Upper threshold", false, -400, "value (-400)" );
37 TCLAP::CmdLine cmd( "Labelling", ' ', "1.0.0" );
41 cmd.add( vesselness );
44 cmd.parse( argc, argv );
46 catch( TCLAP::ArgException& err )
49 << "===============================" << std::endl
50 << "Error caught: " << std::endl
51 << err.error( ) << " " << err.argId( ) << std::endl
52 << "===============================" << std::endl
61 TImage::Pointer input_image;
62 CTBronchi::ReadImage( input_image, in.getValue( ) );
65 TLabels::Pointer input_labels;
66 CTBronchi::ReadImage( input_labels, labels.getValue( ) );
68 // Read input vesselness
69 TScalarImage::Pointer input_vesselness;
70 CTBronchi::ReadImage( input_vesselness, vesselness.getValue( ) );
73 typedef CTBronchi::MoriLabelling< TImage, TLabels, TScalarImage > _TLabelling;
74 _TLabelling::Pointer labelling = _TLabelling::New( );
75 labelling->SetInput( input_image );
76 labelling->SetInputLabels( input_labels );
77 labelling->SetInputVesselness( input_vesselness );
78 labelling->SetVesselnessThreshold( vThr.getValue( ) );
79 labelling->SetUpperThreshold( uThr.getValue( ) );
80 labelling->SetInsideValue( 1 );
81 labelling->SetOutsideValue( 2 );
82 labelling->SetFillValue( 2 );
83 double t = CTBronchi::MeasureTime( labelling );
84 std::cout << "Labelling executed in " << t << " s" << std::endl;
87 CTBronchi::WriteImage( labelling->GetOutput( ), out.getValue( ) );
89 catch( std::exception& err )
92 << "===============================" << std::endl
93 << "Error caught: " << std::endl
94 << err.what( ) << std::endl
95 << "===============================" << std::endl