int main( int argc, char * argv[] )
{
if( argc < 6 )
{
std::cerr << "Usage: " << std::endl;
std::cerr << argv[0] << " inputImageFile outputGradientImageFile ";
std::cerr << "outputSmoothedGradientImageFile ";
std::cerr << "numberOfIterations timeStep" << std::endl;
return EXIT_FAILURE;
}
using InputPixelType = float;
ReaderType::Pointer reader = ReaderType::New();
reader->SetFileName( argv[1] );
VectorImageType, VectorImageType >;
FilterType::Pointer filter = FilterType::New();
InputImageType, VectorImageType >;
GradientFilterType::Pointer gradient = GradientFilterType::New();
gradient->SetInput( reader->GetOutput() );
filter->SetInput( gradient->GetOutput() );
const unsigned int numberOfIterations = std::stoi( argv[4] );
const double timeStep = std::stod( argv[5] );
filter->SetNumberOfIterations( numberOfIterations );
filter->SetTimeStep( timeStep );
filter->SetConductanceParameter(1.0);
filter->Update();
using OutputPixelType = float;
VectorImageType, OutputImageType >;
ComponentFilterType::Pointer component = ComponentFilterType::New();
component->SetIndex( 0 );
using WritePixelType = unsigned char;
OutputImageType, WriteImageType >;
RescaleFilterType::Pointer rescaler = RescaleFilterType::New();
rescaler->SetOutputMinimum( 0 );
rescaler->SetOutputMaximum( 255 );
WriterType::Pointer writer = WriterType::New();
rescaler->SetInput( component->GetOutput() );
writer->SetInput( rescaler->GetOutput() );
component->SetInput( gradient->GetOutput() );
writer->SetFileName( argv[2] );
writer->Update();
component->SetInput( filter->GetOutput() );
writer->SetFileName( argv[3] );
writer->Update();
return EXIT_SUCCESS;
}