// ========================================================================= // @author Leonardo Florez Valencia // @email florez-l@javeriana.edu.co // ========================================================================= #include #include #include #include "MoriLabelling.h" #include "Functions.h" // ------------------------------------------------------------------------- const unsigned int Dim = 3; typedef short TPixel; typedef unsigned char TLabel; typedef itk::NumericTraits< TPixel >::RealType TScalar; typedef itk::Image< TPixel, Dim > TImage; typedef itk::Image< TLabel, Dim > TLabels; typedef itk::Image< TScalar, Dim > TScalarImage; // ------------------------------------------------------------------------- int main( int argc, char* argv[] ) { typedef TCLAP::ValueArg< std::string > _TStringArg; typedef TCLAP::ValueArg< double > _TRealArg; typedef TCLAP::ValueArg< TPixel > _TPixelArg; // Parse input line _TStringArg in( "i", "input", "Input image", true, "", "file" ); _TStringArg labels( "l", "labels", "Input labels", true, "", "file" ); _TStringArg vesselness( "v", "vesselness", "Input vesselness", true, "", "file" ); _TStringArg out( "o", "output", "Output image", true, "", "file" ); _TRealArg vThr( "a", "vesselness_thr", "Vesselness threshold (%)", false, 5, "value (5)" ); _TPixelArg uThr( "u", "upper_thr", "Upper threshold", false, -400, "value (-400)" ); try { TCLAP::CmdLine cmd( "Labelling", ' ', "1.0.0" ); cmd.add( uThr ); cmd.add( vThr ); cmd.add( out ); cmd.add( vesselness ); cmd.add( labels ); cmd.add( in ); cmd.parse( argc, argv ); } catch( TCLAP::ArgException& err ) { std::cerr << "===============================" << std::endl << "Error caught: " << std::endl << err.error( ) << " " << err.argId( ) << std::endl << "===============================" << std::endl << std::endl; return( 1 ); } // yrt try { // Read input image TImage::Pointer input_image; CTBronchi::ReadImage( input_image, in.getValue( ) ); // Read input labels TLabels::Pointer input_labels; CTBronchi::ReadImage( input_labels, labels.getValue( ) ); // Read input vesselness TScalarImage::Pointer input_vesselness; CTBronchi::ReadImage( input_vesselness, vesselness.getValue( ) ); // Create labels typedef CTBronchi::MoriLabelling< TImage, TLabels, TScalarImage > _TLabelling; _TLabelling::Pointer labelling = _TLabelling::New( ); labelling->SetInput( input_image ); labelling->SetInputLabels( input_labels ); labelling->SetInputVesselness( input_vesselness ); labelling->SetVesselnessThreshold( vThr.getValue( ) ); labelling->SetUpperThreshold( uThr.getValue( ) ); labelling->SetInsideValue( 1 ); labelling->SetOutsideValue( 2 ); labelling->SetFillValue( 2 ); double t = CTBronchi::MeasureTime( labelling ); std::cout << "Labelling executed in " << t << " s" << std::endl; // Write result CTBronchi::WriteImage( labelling->GetOutput( ), out.getValue( ) ); } catch( std::exception& err ) { std::cerr << "===============================" << std::endl << "Error caught: " << std::endl << err.what( ) << std::endl << "===============================" << std::endl << std::endl; return( 1 ); } // yrt return( 0 ); } // eof - $RCSfile$