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;
}
typedef float InputPixelType;
ReaderType::Pointer reader = ReaderType::New();
reader->SetFileName( argv[1] );
VectorImageType, VectorImageType > FilterType;
FilterType::Pointer filter = FilterType::New();
InputImageType, VectorImageType > GradientFilterType;
GradientFilterType::Pointer gradient = GradientFilterType::New();
gradient->SetInput( reader->GetOutput() );
filter->SetInput( gradient->GetOutput() );
const unsigned int numberOfIterations = atoi( argv[4] );
const double timeStep = atof( argv[5] );
filter->SetNumberOfIterations( numberOfIterations );
filter->SetTimeStep( timeStep );
filter->SetConductanceParameter(1.0);
filter->Update();
typedef float OutputPixelType;
VectorImageType, OutputImageType > ComponentFilterType;
ComponentFilterType::Pointer component = ComponentFilterType::New();
component->SetIndex( 0 );
typedef unsigned char WritePixelType;
OutputImageType, WriteImageType > RescaleFilterType;
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;
}