+ // Wait for a seed to be given
+ while( view.GetNumberOfSeeds( ) == 0 )
+ view.Start( );
+
+ // Convert seed
+ double seed[ 3 ];
+ view.GetSeed( 0, seed );
+ TImage::PointType seed_pnt;
+ seed_pnt[ 0 ] = seed[ 0 ];
+ seed_pnt[ 1 ] = seed[ 1 ];
+ seed_pnt[ 2 ] = seed[ 2 ];
+ TImage::IndexType seed_idx;
+ input_image->TransformPhysicalPointToIndex( seed_pnt, seed_idx );
+
+ // Configure algorithm
+ TFrontAlgorithm::Pointer algorithm = TFrontAlgorithm::New( );
+ algorithm->AddThresholds( thr_0, thr_1, step );
+ algorithm->AddSeed( seed_idx, 0 );
+ algorithm->SetInput( input_image );
+ algorithm->SetNeighborhoodOrder( 1 );
+ algorithm->SetDifferenceThreshold( double( 3 ) );
+
+ if( visual_debug )
+ {
+ // Configure observer
+ TObserver::Pointer obs = TObserver::New( );
+ obs->SetImage( input_image, view.GetWindow( ) );
+ algorithm->AddObserver( itk::AnyEvent( ), obs );
+ algorithm->ThrowEventsOn( );
+ }
+ else
+ algorithm->ThrowEventsOff( );
+
+ std::clock_t start = std::clock( );
+ algorithm->Update( );
+ std::clock_t end = std::clock( );
+ double seconds = double( end - start ) / double( CLOCKS_PER_SEC );
+ std::cout << "Execution time = " << seconds << std::endl;
+
+ // Show result
+ TVTKImage::Pointer output_image_vtk = TVTKImage::New( );
+ output_image_vtk->SetInput( algorithm->GetOutput( ) );
+ output_image_vtk->Update( );
+
+ vtkSmartPointer< vtkImageMarchingCubes > mc =
+ vtkSmartPointer< vtkImageMarchingCubes >::New( );
+ mc->SetInputData( output_image_vtk->GetOutput( ) );
+ mc->SetValue(
+ 0,
+ double( algorithm->GetInsideValue( ) ) * double( 0.95 )
+ );
+ mc->Update( );
+
+ // Let some interaction and close program
+ view.AddPolyData( mc->GetOutput( ), 0.1, 0.6, 0.8, 0.5 );
+ view.Start( );