1 #include "BaseFunctions.h"
3 #include <fpa/Image/Mori.h>
5 // -------------------------------------------------------------------------
6 const unsigned int Dim = 2;
7 typedef unsigned char TPixel;
9 typedef itk::Image< TPixel, Dim > TImage;
10 typedef fpa::Image::Mori< TImage, TImage > TFilter;
12 // -------------------------------------------------------------------------
13 int main( int argc, char* argv[] )
19 << "Usage: " << argv[ 0 ]
20 << " input_image output_image output_levels"
21 << " init_threshold end_threshold number_of_threshold seed_x seed_y"
26 std::string input_image_filename = argv[ 1 ];
27 std::string output_image_filename = argv[ 2 ];
28 std::string output_levels_filename = argv[ 3 ];
29 unsigned char init_threshold = std::atoi( argv[ 4 ] );
30 unsigned char end_threshold = std::atoi( argv[ 5 ] );
31 unsigned char number_of_thresholds = std::atoi( argv[ 6 ] );
32 TImage::IndexType seed;
33 seed[ 0 ] = std::atoi( argv[ 7 ] );
34 seed[ 1 ] = std::atoi( argv[ 8 ] );
37 TImage::Pointer input_image;
39 fpa::tests::image::Read( input_image, input_image_filename );
40 if( err0 != "" ) std::cerr << err0 << std::endl;
43 TFilter::Pointer filter = TFilter::New( );
44 filter->SetInput( input_image );
45 filter->SetSeed( seed );
46 filter->SetThresholds( init_threshold, end_threshold, number_of_thresholds );
47 filter->SetInsideValue( 255 );
48 filter->SetOutsideValue( 0 );
55 fpa::tests::image::Write( filter->GetOutput( ), output_image_filename );
57 fpa::tests::image::Write( filter->GetOutputLevels( ), output_levels_filename );
58 if( err1 != "" ) std::cerr << err1 << std::endl;
59 if( err2 != "" ) std::cerr << err2 << std::endl;