int
main(int argc, char * argv[])
{
if (argc < 3)
{
std::cerr << "Missing Parameters " << std::endl;
std::cerr << "Usage: " << argv[0];
std::cerr << " inputImageFile outputImageFile" << std::endl;
return EXIT_FAILURE;
}
const std::string inputImageFile = argv[1];
const std::string outputImageFile = argv[2];
reader->SetFileName(inputImageFile);
using GradientMagnitudeImageFilter =
grad->SetInput(reader->GetOutput());
grad->UseImageSpacingOn();
using GradientMagnitudeOutputImageType =
GradientMagnitudeImageFilter::OutputImageType;
using ComposeRGBFilterType =
composeRGB->SetInput1(grad->GetOutput());
composeRGB->SetInput2(grad->GetOutput());
composeRGB->SetInput3(grad->GetOutput());
composeRGB->UpdateOutputInformation();
composeRGB->GetOutput()->GetLargestPossibleRegion();
largest.GetIndex(0) +
static_cast<unsigned long>(0.25 * largest.GetSize(0)));
largest.GetIndex(1) +
static_cast<unsigned long>(0.25 * largest.GetSize(1)));
halfIO.
SetSize(0, static_cast<unsigned long>(0.5 * largest.GetSize(0)));
halfIO.
SetSize(1, static_cast<unsigned long>(0.5 * largest.GetSize(1)));
using ToVectorImageAdaptorType =
adaptor->SetImage(composeRGB->GetOutput());
writer->SetFileName(outputImageFile);
writer->SetNumberOfStreamDivisions(10);
writer->SetIORegion(halfIO);
writer->SetInput(adaptor);
try
{
writer->Update();
}
{
std::cerr << "ExceptionObject caught !" << std::endl;
std::cerr << err << std::endl;
return EXIT_FAILURE;
}
return EXIT_SUCCESS;
}