1 #include "BaseFunctions.h"
3 #include <fpa/Image/RandomWalker.h>
4 #include <fpa/Image/Functors/Dijkstra/Gaussian.h>
6 // -------------------------------------------------------------------------
7 const unsigned int Dim = 2;
9 typedef unsigned char TLabel;
10 typedef float TScalar;
12 typedef itk::Image< TPixel, Dim > TInputImage;
13 typedef itk::Image< TLabel, Dim > TLabelImage;
14 typedef fpa::Image::RandomWalker< TInputImage, TLabelImage, TScalar > TFilter;
15 typedef fpa::Image::Functors::Dijkstra::Gaussian< TInputImage, TScalar > TWeight;
17 // -------------------------------------------------------------------------
18 int main( int argc, char* argv[] )
24 << "Usage: " << argv[ 0 ]
25 << " input_image labels_image output_image output_costs"
31 std::string input_image_filename = argv[ 1 ];
32 std::string labels_image_filename = argv[ 2 ];
33 std::string output_image_filename = argv[ 3 ];
34 std::string output_costs_filename = argv[ 4 ];
35 double alpha = std::atof( argv[ 5 ] );
36 double beta = std::atof( argv[ 6 ] );
39 TInputImage::Pointer image;
40 std::string err0 = fpa::tests::image::Read( image, input_image_filename );
43 std::cerr << "Error caught: " << err0 << std::endl;
49 TLabelImage::Pointer labels;
50 std::string err1 = fpa::tests::image::Read( labels, labels_image_filename );
53 std::cerr << "Error caught: " << err1 << std::endl;
59 TWeight::Pointer weight = TWeight::New( );
60 weight->SetAlpha( alpha );
61 weight->SetBeta( beta );
64 TFilter::Pointer filter = TFilter::New( );
65 filter->SetInput( image );
66 filter->SetWeightFunction( weight );
67 filter->SetLabels( labels );
74 catch( std::exception& err )
76 std::cerr << "Error caught: " << err.what( ) << std::endl;
83 fpa::tests::image::Write( filter->GetMarks( ), output_image_filename );
85 fpa::tests::image::Write( filter->GetOutput( ), output_costs_filename );
86 if( err2 != "" ) std::cerr << "Error caught: " << err2 << std::endl;
87 if( err3 != "" ) std::cerr << "Error caught: " << err3 << std::endl;