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 beta = std::atof( argv[ 5 ] );
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 TLabelImage::Pointer labels;
49 std::string err1 = fpa::tests::image::Read( labels, labels_image_filename );
52 std::cerr << "Error caught: " << err1 << std::endl;
58 TWeight::Pointer weight = TWeight::New( );
59 weight->SetBeta( beta );
62 TFilter::Pointer filter = TFilter::New( );
63 filter->SetInput( image );
64 filter->SetWeightFunction( weight );
65 filter->SetLabels( labels );
72 catch( std::exception& err )
74 std::cerr << "Error caught: " << err.what( ) << std::endl;
81 fpa::tests::image::Write( filter->GetMarks( ), output_image_filename );
83 fpa::tests::image::Write( filter->GetOutput( ), output_costs_filename );
84 if( err2 != "" ) std::cerr << "Error caught: " << err2 << std::endl;
85 if( err3 != "" ) std::cerr << "Error caught: " << err3 << std::endl;