1 #include "BaseFunctions.h"
3 #include <fpa/Image/Dijkstra.h>
4 #include <fpa/Image/Functors/Dijkstra/Identity.h>
6 // -------------------------------------------------------------------------
7 const unsigned int Dim = 2;
8 typedef unsigned char TPixel;
11 typedef itk::Image< TPixel, Dim > TInputImage;
12 typedef itk::Image< TScalar, Dim > TScalarImage;
13 typedef fpa::Image::Dijkstra< TInputImage, TScalarImage > TFilter;
14 typedef fpa::Image::Functors::Dijkstra::Identity< TInputImage, TScalar > TWeight;
16 // -------------------------------------------------------------------------
17 int main( int argc, char* argv[] )
23 << "Usage: " << argv[ 0 ]
24 << " output_image output_marks width height visual_debug ..."
29 std::string output_image_filename = argv[ 1 ];
30 std::string output_marks_filename = argv[ 2 ];
31 int width = std::atoi( argv[ 3 ] );
32 int height = std::atoi( argv[ 4 ] );
33 bool visual_debug = ( argv[ 5 ][ 0 ] == '1' );
36 TInputImage::Pointer image;
37 fpa::tests::image::CreateImage( image, 1, width, height, 1.0, 1.0 );
39 // Interact with image
40 fpa::tests::image::Viewer< TFilter > viewer( image );
43 viewer.ActivateSeedWidget( );
49 TWeight::Pointer weight = TWeight::New( );
52 TFilter::Pointer filter = TFilter::New( );
53 filter->SetInput( image );
54 filter->SetWeightFunction( weight );
57 for( int i = 6; i < argc; i += 2 )
61 TInputImage::IndexType seed;
62 seed[ 0 ] = std::atoi( argv[ i ] );
63 seed[ 1 ] = std::atoi( argv[ i + 1 ] );
64 filter->AddSeed( seed );
69 viewer.AssociateSeedsTo( filter );
71 // Prepare visual debug and update
73 viewer.ObserveFilter( filter );
78 fpa::tests::image::Write( filter->GetOutput( ), output_image_filename );
80 fpa::tests::image::Write( filter->GetMarks( ), output_marks_filename );
81 if( err1 != "" ) std::cerr << err1 << std::endl;
82 if( err2 != "" ) std::cerr << err2 << std::endl;