#include #include #include #include #include #include #include // ------------------------------------------------------------------------- static const unsigned int VDim = 2; typedef float TScalar; typedef itk::Image< unsigned char, VDim > TInputImage; typedef itk::Image< TScalar, VDim > TOutputImage; typedef itk::RandomImageSource< TInputImage > TImageSource; typedef itk::ImageFileWriter< TOutputImage > TImageWriter; typedef fpa::Image::Functors::SimpleNeighborhood< TInputImage > TNeighFunction; typedef fpa::Image::Functors::SimpleDijkstraCost< TInputImage, TScalar > TCostFunction; typedef fpa::Base::Functors::Inverse< TScalar, TScalar > TCostConversionFunction; typedef fpa::Image::Dijkstra< TInputImage, TOutputImage > TFilter; // ------------------------------------------------------------------------- int main( int argc, char* argv[] ) { static const unsigned long SIZE = 100; unsigned long size[] = { SIZE, SIZE }; unsigned int neigh_order = 1; TInputImage::IndexType seed0, seed1; seed0.Fill( 0 ); seed1.Fill( SIZE - 1 ); TImageSource::Pointer source = TImageSource::New( ); source->SetSize( size ); source->SetSpacing( 1 ); source->Update( ); TInputImage::Pointer input = source->GetOutput( ); TNeighFunction::Pointer neigh_function = TNeighFunction::New( ); neigh_function->SetOrder( neigh_order ); TCostFunction::Pointer cost_function = TCostFunction::New( ); TCostConversionFunction::Pointer cost_conversion_function = TCostConversionFunction::New( ); TFilter::Pointer filter = TFilter::New( ); filter->SetInput( input ); filter->SetNeighborhoodFunction( neigh_function ); filter->SetCostFunction( cost_function ); filter->SetCostConversionFunction( cost_conversion_function ); filter->AddSeed( seed0, 0 ); filter->AddSeed( seed1, 0 ); filter->StopAtOneFrontOn( ); filter->Update( ); TImageWriter::Pointer writer = TImageWriter::New( ); writer->SetInput( filter->GetOutput( ) ); writer->SetFileName( "dijkstra.mhd" ); writer->Update( ); return( 0 ); } // eof - $RCSfile$