#include <sstream>
int main(int argc, char * argv[])
{
if( argc < 2 )
{
std::cerr << "Usage: " << std::endl;
std::cerr << argv[0] << " InputImageFile [iterations]" << std::endl;
return EXIT_FAILURE;
}
int iterations = 5;
if (argc > 2)
{
std::stringstream ss(argv[2]);
ss >> iterations;
}
std::string inputFilename = argv[1];
using ComponentType = float;
ReaderType::Pointer reader = ReaderType::New();
reader->SetFileName( inputFilename );
reader->Update();
ImageAdaptorType::Pointer rAdaptor =
ImageAdaptorType::New();
rAdaptor->SelectNthElement(0);
rAdaptor->SetImage(reader->GetOutput());
CurvatureFlowType::Pointer rCurvatureFilter =
CurvatureFlowType::New();
rCurvatureFilter->SetInput(rAdaptor);
rCurvatureFilter->SetNumberOfIterations(iterations);
rCurvatureFilter->Update();
ImageAdaptorType::Pointer gAdaptor =
ImageAdaptorType::New();
gAdaptor->SelectNthElement(1);
gAdaptor->SetImage(reader->GetOutput());
CurvatureFlowType::Pointer gCurvatureFilter =
CurvatureFlowType::New();
gCurvatureFilter->SetInput(gAdaptor);
gCurvatureFilter->SetNumberOfIterations(iterations);
gCurvatureFilter->Update();
ImageAdaptorType::Pointer bAdaptor =
ImageAdaptorType::New();
bAdaptor->SelectNthElement(2);
bAdaptor->SetImage(reader->GetOutput());
CurvatureFlowType::Pointer bCurvatureFilter =
CurvatureFlowType::New();
bCurvatureFilter->SetInput(bAdaptor);
bCurvatureFilter->SetNumberOfIterations(iterations);
bCurvatureFilter->Update();
ComposeType::Pointer compose =
ComposeType::New();
compose->SetInput1 (rCurvatureFilter->GetOutput());
compose->SetInput2 (gCurvatureFilter->GetOutput());
compose->SetInput3 (bCurvatureFilter->GetOutput());
reader->GetOutput(),
true,
itksys::SystemTools::GetFilenameName(inputFilename));
std::stringstream desc;
desc << "MinMaxCurvatureFlow iterations = " << iterations;
compose->GetOutput(),
true,
desc.str());
return EXIT_SUCCESS;
}