1 #include "BaseFunctions.h"
3 #include <fpa/Image/Dijkstra.h>
4 #include <fpa/Image/Functors/Dijkstra/Gaussian.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::Gaussian< TInputImage, TScalar > TWeight;
16 // -------------------------------------------------------------------------
17 int main( int argc, char* argv[] )
23 << "Usage: " << argv[ 0 ]
24 << " input_image output_image output_marks alpha beta"
25 << " stop_at_one_front visual_debug ..."
30 std::string input_image_filename = argv[ 1 ];
31 std::string output_image_filename = argv[ 2 ];
32 std::string output_marks_filename = argv[ 3 ];
33 double alpha = std::atoi( argv[ 4 ] );
34 double beta = std::atoi( argv[ 5 ] );
35 bool stop_at_one_front = ( argv[ 6 ][ 0 ] == '1' );
36 bool visual_debug = ( argv[ 7 ][ 0 ] == '1' );
39 TInputImage::Pointer image;
40 std::string err0 = fpa::tests::image::Read( image, input_image_filename );
43 std::cerr << "Error caught: " << err0 << std::endl;
48 // Interact with image
49 fpa::tests::image::Viewer< TFilter > viewer( image );
52 viewer.ActivateSeedWidget( );
58 TWeight::Pointer weight = TWeight::New( );
59 weight->SetAlpha( alpha );
60 weight->SetBeta( beta );
63 TFilter::Pointer filter = TFilter::New( );
64 filter->SetInput( image );
65 filter->SetWeightFunction( weight );
66 filter->SetStopAtOneFront( stop_at_one_front );
69 for( int i = 8; i < argc; i += 2 )
73 TInputImage::IndexType seed;
74 seed[ 0 ] = std::atoi( argv[ i ] );
75 seed[ 1 ] = std::atoi( argv[ i + 1 ] );
76 filter->AddSeed( seed );
81 viewer.AssociateSeedsTo( filter );
83 // Prepare visual debug and update
85 viewer.ObserveFilter( filter );
90 fpa::tests::image::Write( filter->GetOutput( ), output_image_filename );
92 fpa::tests::image::Write( filter->GetMarks( ), output_marks_filename );
93 if( err1 != "" ) std::cerr << "Error caught: " << err1 << std::endl;
94 if( err2 != "" ) std::cerr << "Error caught: " << err2 << std::endl;