// -------------------------------------------------------------------------
int main( int argc, char* argv[] )
{
- if( argc < 6 )
+ if( argc < 4 )
{
std::cerr
<< "Usage: " << argv[ 0 ]
- << " input_image x y z output_image"
+ << " input_image output_image"
+ << " neighborhood_order"
<< " visual_debug"
<< std::endl;
return( 1 );
} // fi
std::string input_image_fn = argv[ 1 ];
- TImage::IndexType seed_idx;
- seed_idx[ 0 ] = std::atoi( argv[ 2 ] );
- seed_idx[ 1 ] = std::atoi( argv[ 3 ] );
- seed_idx[ 2 ] = std::atoi( argv[ 4 ] );
- std::string output_image_fn = argv[ 5 ];
+ std::string output_image_fn = argv[ 2 ];
+ unsigned int neighborhood_order = std::atoi( argv[ 3 ] );
bool visual_debug = false;
- if( argc > 6 )
- visual_debug = ( std::atoi( argv[ 6 ] ) == 1 );
+ if( argc > 4 )
+ visual_debug = ( std::atoi( argv[ 4 ] ) == 1 );
// Read image
TImageReader::Pointer input_image_reader = TImageReader::New( );
view.SetSize( 800, 800 );
view.SetImage( vtk_image->GetOutput( ) );
- // Allow some interaction
- view.Start( );
+ // Wait for a seed to be given
+ while( view.GetNumberOfSeeds( ) == 0 )
+ view.Start( );
+
+ // Get seed from user
+ 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 );
// Extract paths
TDijkstra::Pointer paths = TDijkstra::New( );
paths->AddSeed( seed_idx, TScalar( 0 ) );
paths->SetInput( input_image );
- paths->SetNeighborhoodOrder( 1 );
+ paths->SetNeighborhoodOrder( neighborhood_order );
if( visual_debug )
{
distanceMap->SetInput( segmentor->GetOutput( ) );
distanceMap->InputIsBinaryOn( );
distanceMap->SquaredDistanceOn( );
+ distanceMap->UseImageSpacingOn( );
start = std::clock( );
distanceMap->Update( );
end = std::clock( );
TDijkstra::Pointer paths = TDijkstra::New( );
paths->AddSeed( segmentor->GetSeed( 0 ), TScalar( 0 ) );
paths->SetInput( distanceMap->GetOutput( ) );
- paths->SetNeighborhoodOrder( 1 );
+ paths->SetNeighborhoodOrder( 2 );
if( visual_debug )
{
for( unsigned int d = 0; d < I::ImageDimension; d++ )
dist += std::abs( long( a[ d ] ) - long( b[ d ] ) );
if( this->m_NeighborhoodOrder == 1 )
- return( dist == 0 || dist == 1 );
+ return( dist <= 1 );
else
- return( dist == 0 || dist == 1 || dist == 2 );
+ return( dist <= I::ImageDimension );
}
// -------------------------------------------------------------------------