2 #include <itkRandomImageSource.h>
3 #include <itkImageFileWriter.h>
5 #include <fpa/Image/Functors/SimpleNeighborhood.h>
6 #include <fpa/Image/Functors/SimpleDijkstraCost.h>
7 #include <fpa/Base/Functors/Inverse.h>
8 #include <fpa/Image/Dijkstra.h>
10 // -------------------------------------------------------------------------
11 static const unsigned int VDim = 2;
12 typedef float TScalar;
13 typedef itk::Image< unsigned char, VDim > TInputImage;
14 typedef itk::Image< TScalar, VDim > TOutputImage;
16 typedef itk::RandomImageSource< TInputImage > TImageSource;
17 typedef itk::ImageFileWriter< TOutputImage > TImageWriter;
19 typedef fpa::Image::Functors::SimpleNeighborhood< TInputImage > TNeighFunction;
20 typedef fpa::Image::Functors::SimpleDijkstraCost< TInputImage, TScalar > TCostFunction;
21 typedef fpa::Base::Functors::Inverse< TScalar, TScalar > TCostConversionFunction;
23 typedef fpa::Image::Dijkstra< TInputImage, TOutputImage > TFilter;
25 // -------------------------------------------------------------------------
26 int main( int argc, char* argv[] )
28 static const unsigned long SIZE = 100;
29 unsigned long size[] = { SIZE, SIZE };
31 unsigned int neigh_order = 1;
32 TInputImage::IndexType seed0, seed1;
35 seed1.Fill( SIZE - 1 );
37 TImageSource::Pointer source = TImageSource::New( );
38 source->SetSize( size );
39 source->SetSpacing( 1 );
41 TInputImage::Pointer input = source->GetOutput( );
43 TNeighFunction::Pointer neigh_function = TNeighFunction::New( );
44 neigh_function->SetOrder( neigh_order );
46 TCostFunction::Pointer cost_function = TCostFunction::New( );
48 TCostConversionFunction::Pointer cost_conversion_function =
49 TCostConversionFunction::New( );
51 TFilter::Pointer filter = TFilter::New( );
52 filter->SetInput( input );
53 filter->SetNeighborhoodFunction( neigh_function );
54 filter->SetCostFunction( cost_function );
55 filter->SetCostConversionFunction( cost_conversion_function );
56 filter->AddSeed( seed0, 0 );
57 filter->AddSeed( seed1, 0 );
58 filter->StopAtOneFrontOn( );
61 TImageWriter::Pointer writer = TImageWriter::New( );
62 writer->SetInput( filter->GetOutput( ) );
63 writer->SetFileName( "dijkstra.mhd" );