- if( ParseArgs( args, argc, argv ) )
- {
- // Read input image
- TImage::Pointer input_image;
- ReadImage( input_image, args[ "in" ] );
-
- // Read labels image
- TLabels::Pointer input_labels;
- ReadImage( input_labels, args[ "labels" ] );
-
- // Mori segmentation
- /* TODO
- typedef fpa::Filters::Image::Mori< TImage, TLabels > TMori;
- TMori::Pointer mori = TMori::New( );
- mori->SetInput( input_image );
- mori->SetSeed( seed );
- mori->SetInsideValue( 1 );
- mori->SetOutsideValue( 0 );
- mori->SetMinimumThreshold(
- TPixel( std::atof( args[ "minimum_threshold" ].c_str( ) ) )
- );
- mori->SetSignalKernelSize(
- std::atoi( args[ "signal_kernel_size" ].c_str( ) )
- );
- mori->SetSignalThreshold(
- std::atof( args[ "signal_threshold" ].c_str( ) )
- );
- mori->SetSignalInfluence(
- std::atof( args[ "signal_influence" ].c_str( ) )
- );
- mori->SetThresholds(
- TPixel( std::atof( args[ "lower_threshold" ].c_str( ) ) ),
- TPixel( std::atof( args[ "upper_threshold" ].c_str( ) ) ),
- TPixel( std::atof( args[ "delta_threshold" ].c_str( ) ) )
- );
- double t = MeasureTime( mori );
- std::cout << "Mori executed in " << t << " s" << std::endl;
- WriteImage( mori->GetOutput( ), args[ "out" ] );
-
- std::map< std::string, std::string >::const_iterator i =
- args.find( "out_signal" );
- if( i != args.end( ) )
- {
- std::stringstream signal;
- unsigned long nthr = mori->GetNumberOfEvaluatedThresholds( );
- signal << "# nThr = " << nthr << std::endl;
- signal << "# Opt = " << mori->GetOptimumThreshold( ) << std::endl;
- for( unsigned long j = 0; j < nthr; ++j )
- {
- typename TMori::TPeak p;
- double x, y;
- mori->GetSignalValues( j, x, y, p );
- signal << x << " " << y << std::endl;
-
- } // rof
- std::ofstream signals_str( i->second.c_str( ) );
- signals_str << signal.str( );
- signals_str.close( );
-
- } // fi
- */
- }
- else
- return( 1 );
+ // 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( ) );