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 ..."
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' );
38 TInputImage::Pointer image;
39 std::string err0 = fpa::tests::image::Read( image, input_image_filename );
42 std::cerr << "Error caught: " << err0 << std::endl;
48 TWeight::Pointer weight = TWeight::New( );
49 weight->SetAlpha( alpha );
50 weight->SetBeta( beta );
53 TFilter::Pointer filter = TFilter::New( );
54 filter->SetInput( image );
55 filter->SetWeightFunction( weight );
56 filter->SetStopAtOneFront( stop_at_one_front );
59 for( int i = 7; i < argc; i += 2 )
63 TInputImage::IndexType seed;
64 seed[ 0 ] = std::atoi( argv[ i ] );
65 seed[ 1 ] = std::atoi( argv[ i + 1 ] );
66 filter->AddSeed( seed );
77 fpa::tests::image::Write( filter->GetOutput( ), output_image_filename );
79 fpa::tests::image::Write( filter->GetMarks( ), output_marks_filename );
80 if( err1 != "" ) std::cerr << "Error caught: " << err1 << std::endl;
81 if( err2 != "" ) std::cerr << "Error caught: " << err2 << std::endl;